Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
AIOCommand.run = async (argv, opts) => {
if (!argv) {
argv = process.argv.slice(2)
}
// oclif originally included the following too ...
// this resulted in an uncovered line in the tests, and it appeared to never happen anyway
// seem like it would only
// || module.parent && module.parent.parent && module.parent.parent.filename
const config = await Config.load(opts || __dirname)
let subCommand = argv[0]
// 1. find the first flag ( note: there could be none ... )
let firstFlag = argv.slice().findIndex(elem => elem.indexOf('-') === 0)
if (firstFlag < 0) {
firstFlag = argv.length
}
// 2. try to make the biggest topic command by combining with ':'
// and looking up in this.config.commandIDs
for (let x = firstFlag; x > -1; x--) {
subCommand = argv.slice(0, x).join(':')
// if (config.findTopic(subCommand)) { // <= this works but does not support aliases
if (config.findCommand(subCommand)) {
argv = [subCommand].concat(argv.slice(x))
break
beforeEach(async () => {
config = await require('@oclif/config').load()
cli.mockConsole()
cli.exit.mock()
})
afterEach(() => nock.cleanAll())
async function run() {
const config = await Config.load({root: __dirname})
const analytics = new Analytics(config)
await analytics.submit()
}
run()