fix(core): update

This commit is contained in:
2022-08-03 18:47:35 +02:00
parent 19f0a9563f
commit 04deb8960c
3 changed files with 21 additions and 35 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartcli',
version: '4.0.1',
version: '4.0.2',
description: 'easy observable cli tasks'
}

View File

@ -18,7 +18,6 @@ export class Smartcli {
public parseCompleted = plugins.smartpromise.defer<any>();
public version: string;
private checkForEnvCliCall = true;
/**
* map of all Trigger/Observable objects to keep track
@ -35,13 +34,6 @@ export class Smartcli {
*/
constructor() {}
/**
* halts any execution of commands if (process.env.CLI_CALL === false)
*/
disableEnvCliCall() {
this.checkForEnvCliCall = false;
}
/**
* adds an alias, meaning one equals the other in terms of command execution.
*/
@ -123,19 +115,12 @@ export class Smartcli {
* start the process of evaluating commands
*/
public startParse(): void {
// if we check for cli env calls, we might want to abort here.
if (!process.env.CLI_CALL && this.checkForEnvCliCall) {
console.log(
`note: @pushrocks/smartcli: You called .startParse() on a SmartCli instance. However process.env.CLI_CALL being absent prevented parsing.`
);
return;
}
const parsedYArgs = plugins.yargsParser(process.argv);
// lets handle commands
let counter = 0;
let foundCommand = false;
parsedYArgs._.map((commandPartArg) => {
parsedYArgs._ = parsedYArgs._.filter((commandPartArg) => {
counter++;
if (typeof commandPartArg === 'number') {
return true;
@ -149,7 +134,8 @@ export class Smartcli {
}
});
for (const command of this.commandObservableMap.getArray()) {
if (!parsedYArgs._[0]) {
const wantedCommand = parsedYArgs._[0];
if (!wantedCommand) {
const standardCommand = this.commandObservableMap.findSync((commandArg) => {
return commandArg.commandName === 'standardCommand';
});
@ -160,6 +146,7 @@ export class Smartcli {
}
break;
}
console.log(`Wanted command: ${wantedCommand}`);
if (command.commandName === parsedYArgs._[0]) {
command.subject.next(parsedYArgs);
break;