fix(): Downgrade commander and override default exit behaviour
This commit is contained in:
parent
e29f085961
commit
d6336f4836
|
@ -24,3 +24,5 @@ The iSH-App on iOS has the following latest versions available
|
||||||
- npm v7.17.0
|
- npm v7.17.0
|
||||||
|
|
||||||
These versions are deprecated, but if we want to use these scripts on iSH, we have to make sure they run on that outdated versions.
|
These versions are deprecated, but if we want to use these scripts on iSH, we have to make sure they run on that outdated versions.
|
||||||
|
|
||||||
|
- only commander v11 supports nodejs v16
|
||||||
|
|
12
log
12
log
|
@ -60,16 +60,20 @@ class Log extends This {
|
||||||
/**
|
/**
|
||||||
* @program()
|
* @program()
|
||||||
*/
|
*/
|
||||||
|
this.program.exitOverride();
|
||||||
|
|
||||||
|
try {
|
||||||
this.program.parse();
|
this.program.parse();
|
||||||
|
} catch (err) {
|
||||||
|
// custom processing...
|
||||||
|
}
|
||||||
|
|
||||||
if (Object.keys(this.program.opts()).length || this.program.args.length) {
|
if (Object.keys(this.program.opts()).length || this.program.args.length) {
|
||||||
//// Debugging commander options and arguments
|
//// Debugging commander options and arguments
|
||||||
const opts = util.inspect(this.program.opts(), { depth: null, colors: true, showHidden: true });
|
const opts = util.inspect(this.program.opts(), { depth: null, colors: true, showHidden: true });
|
||||||
const args = util.inspect(this.program.args, { depth: null, colors: true, showHidden: true });
|
const args = util.inspect(this.program.args, { depth: null, colors: true, showHidden: true });
|
||||||
//this.echo(`Options: ${opts}`);
|
this.echo(`Options: ${opts}`);
|
||||||
//this.echo(`Remaining arguments: ${args}`);
|
this.echo(`Remaining arguments: ${args}`);
|
||||||
} else {
|
|
||||||
this.program.outputHelp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -5,7 +5,7 @@
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": "^12.1.0",
|
"commander": "^11.1.0",
|
||||||
"shelljs": "^0.8.5"
|
"shelljs": "^0.8.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -27,11 +27,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/commander": {
|
"node_modules/commander": {
|
||||||
"version": "12.1.0",
|
"version": "11.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
||||||
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
|
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/concat-map": {
|
"node_modules/concat-map": {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"format": "prettier --ignore-path .gitignore --write \"./*\""
|
"format": "prettier --ignore-path .gitignore --write \"./*\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": "^12.1.0",
|
"commander": "^11.1.0",
|
||||||
"shelljs": "^0.8.5"
|
"shelljs": "^0.8.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
12
pm-search
12
pm-search
|
@ -1,23 +1,17 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const This = require('./this');
|
const This = require('./this');
|
||||||
const { Command } = require('commander');
|
|
||||||
const program = new Command();
|
|
||||||
|
|
||||||
class PmSearch extends This {
|
class PmSearch extends This {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.version = '0.0.1';
|
this.version = '0.0.1';
|
||||||
|
this.description = 'Search packages of fake package manager';
|
||||||
|
super.init(); // initialize commander with overridden version and description
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
// Usage
|
super.start();
|
||||||
const pmSearch = new PmSearch();
|
|
||||||
// Output: Methods of ExampleClass: [ 'methodOne', 'methodTwo' ]
|
|
||||||
// Properties of ExampleClass: [ 'propertyOne', 'propertyTwo', 'version' ] and Version: 1.1.0
|
|
||||||
// pmSearch.discovery();
|
|
||||||
|
|
||||||
program.name(this.scriptName).version('0.0.1').description('Search packages of fake package manager').outputHelp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
this
8
this
|
@ -64,7 +64,13 @@ class This {
|
||||||
/**
|
/**
|
||||||
* @program()
|
* @program()
|
||||||
*/
|
*/
|
||||||
|
this.program.exitOverride();
|
||||||
|
|
||||||
|
try {
|
||||||
this.program.parse();
|
this.program.parse();
|
||||||
|
} catch (err) {
|
||||||
|
// custom processing...
|
||||||
|
}
|
||||||
|
|
||||||
if (Object.keys(this.program.opts()).length || this.program.args.length) {
|
if (Object.keys(this.program.opts()).length || this.program.args.length) {
|
||||||
// Debugging commander options and arguments
|
// Debugging commander options and arguments
|
||||||
|
@ -72,8 +78,6 @@ class This {
|
||||||
const args = util.inspect(this.program.args, { depth: null, colors: true, showHidden: true });
|
const args = util.inspect(this.program.args, { depth: null, colors: true, showHidden: true });
|
||||||
this.execCmd(`${this.workingDir}/log echo 'Options: ${opts}'`);
|
this.execCmd(`${this.workingDir}/log echo 'Options: ${opts}'`);
|
||||||
this.execCmd(`${this.workingDir}/log echo 'Remaining arguments: ${args}'`);
|
this.execCmd(`${this.workingDir}/log echo 'Remaining arguments: ${args}'`);
|
||||||
} else {
|
|
||||||
this.program.outputHelp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user