fix tests and add .triggerOnlyOnProcessEnvCliCall()

This commit is contained in:
2017-10-12 22:44:34 +02:00
parent 45d3ce8ffc
commit c7e940f597
8 changed files with 350 additions and 412 deletions

View File

@ -24,6 +24,7 @@ export class Smartcli {
commands
questions
version: string
private onlyOnProcessEnvCliCall = false
/**
* map of all Command/Promise objects to keep track
@ -41,6 +42,10 @@ export class Smartcli {
this.parseStarted = smartq.defer()
}
onlyTriggerOnProcessEnvCliCall () {
this.onlyOnProcessEnvCliCall = true
}
/**
* adds an alias, meaning one equals the other in terms of command execution.
*/
@ -141,7 +146,15 @@ export class Smartcli {
this.parseStarted.promise
.then(() => {
if (this.argv._.length === 0 && !this.argv.v) {
done.resolve(this.argv)
if (this.onlyOnProcessEnvCliCall) {
if (process.env.CLI_CALL === 'true') {
done.resolve(this.argv)
} else {
return
}
} else {
done.resolve(this.argv)
}
}
})
return done.promise