Last active
February 12, 2022 12:11
-
-
Save Souvikns/65838f8adc23734ed04b82c02b000c06 to your computer and use it in GitHub Desktop.
This is how the bundle command would look...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {main, options} from '@asyncapi/bundler/cli'; | |
import bundle from '@asyncapi/bundler'; | |
import Command from './base'; | |
import {Flags} from '@oclif/core'; | |
export default class Bundle extends Command { | |
static strict = false; | |
static flags = options.getFlags(Flags); | |
async run(){ | |
const {argv, flags} = this.parse(Bundle); | |
await main(argv, flags); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bundle = require('./lib'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const main = async (args, flags) => { | |
let basepath; | |
if (flags['base']){ | |
basepath = fs.readFile(path.resolve(process.cwd(), flags['base']), 'utf-8') | |
} | |
const document = await bundle( | |
args.map(filepath => fs.readFileSync(path.resolve(process.cwd(), filepath), 'utf-8')), | |
base: basepath | |
); | |
fs.writeFileSync(path.resolve(process.cwd(), flags['output']), document.yml()); | |
} | |
const options = { | |
getFlags: (Flags) => ({ | |
base: Flags.string({char: 'b'}), | |
output: Flags.string({char: 'o'}) | |
}) | |
} | |
module.exports = { | |
main, | |
options | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment