@oclif/command
Advanced tools
Comparing version 1.5.19 to 1.5.20
@@ -0,1 +1,5 @@ | ||
## [1.5.20](https://github.com/oclif/command/compare/v1.5.19...v1.5.20) (2020-04-20) | ||
## [1.5.19](https://github.com/oclif/command/compare/v1.5.18...v1.5.19) (2019-09-05) | ||
@@ -2,0 +6,0 @@ |
@@ -40,2 +40,5 @@ import * as Config from '@oclif/config'; | ||
* instantiate and run the command | ||
* @param {Config.Command.Class} this Class | ||
* @param {string[]} argv argv | ||
* @param {Config.LoadOptions} opts options | ||
*/ | ||
@@ -42,0 +45,0 @@ static run: Config.Command.Class['run']; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// tslint:disable no-implicit-dependencies | ||
// tslint:disable no-single-line-block-comment | ||
const pjson = require('../package.json'); | ||
@@ -46,5 +44,5 @@ const Config = require("@oclif/config"); | ||
} | ||
catch (e) { | ||
err = e; | ||
await this.catch(e); | ||
catch (error) { | ||
err = error; | ||
await this.catch(error); | ||
} | ||
@@ -55,4 +53,8 @@ finally { | ||
} | ||
exit(code = 0) { return Errors.exit(code); } | ||
warn(input) { Errors.warn(input); } | ||
exit(code = 0) { | ||
return Errors.exit(code); | ||
} | ||
warn(input) { | ||
Errors.warn(input); | ||
} | ||
error(input, options = {}) { | ||
@@ -93,14 +95,12 @@ return Errors.error(input, options); | ||
} | ||
else if (err.message.match(/Unexpected arguments?: (-v|--version|version)(,|\n)/)) { | ||
if (err.message.match(/Unexpected arguments?: (-v|--version|version)(,|\n)/)) { | ||
return this._version(); | ||
} | ||
else { | ||
try { | ||
const { cli } = require('cli-ux'); | ||
const chalk = require('chalk'); | ||
cli.action.stop(chalk.bold.red('!')); | ||
} | ||
catch (_a) { } | ||
throw err; | ||
try { | ||
const { cli } = require('cli-ux'); | ||
const chalk = require('chalk'); // eslint-disable-line node/no-extraneous-require | ||
cli.action.stop(chalk.bold.red('!')); | ||
} | ||
catch (_a) { } | ||
throw err; | ||
} | ||
@@ -114,4 +114,4 @@ async finally(_) { | ||
} | ||
catch (err) { | ||
console.error(err); | ||
catch (error) { | ||
console.error(error); | ||
} | ||
@@ -129,7 +129,7 @@ } | ||
topics = util_2.uniqBy(topics, (t) => t.name); | ||
help.showCommandHelp(cmd, this.config.topics); | ||
help.showCommandHelp(cmd, topics); | ||
return this.exit(0); | ||
} | ||
_helpOverride() { | ||
for (let arg of this.argv) { | ||
for (const arg of this.argv) { | ||
if (arg === '--help') | ||
@@ -156,2 +156,5 @@ return true; | ||
* instantiate and run the command | ||
* @param {Config.Command.Class} this Class | ||
* @param {string[]} argv argv | ||
* @param {Config.LoadOptions} opts options | ||
*/ | ||
@@ -161,6 +164,6 @@ Command.run = async function (argv, opts) { | ||
argv = process.argv.slice(2); | ||
const config = await Config.load(opts || module.parent && module.parent.parent && module.parent.parent.filename || __dirname); | ||
let cmd = new this(argv, config); | ||
const config = await Config.load(opts || (module.parent && module.parent.parent && module.parent.parent.filename) || __dirname); | ||
const cmd = new this(argv, config); | ||
return cmd._run(argv); | ||
}; | ||
exports.default = Command; |
@@ -9,4 +9,4 @@ "use strict"; | ||
} | ||
catch (err) { | ||
if (err.code === 'ENOENT') { | ||
catch (error) { | ||
if (error.code === 'ENOENT') { | ||
process.stderr.write('WARNING: current directory does not exist\n'); | ||
@@ -13,0 +13,0 @@ } |
@@ -6,6 +6,6 @@ "use strict"; | ||
static run(argv = process.argv.slice(2), options) { | ||
return super.run(argv, options || module.parent && module.parent.parent && module.parent.parent.filename || __dirname); | ||
return super.run(argv, options || (module.parent && module.parent.parent && module.parent.parent.filename) || __dirname); | ||
} | ||
async init() { | ||
let [id, ...argv] = this.argv; | ||
const [id, ...argv] = this.argv; | ||
await this.config.runHook('init', { id, argv }); | ||
@@ -15,6 +15,6 @@ return super.init(); | ||
async run() { | ||
let [id, ...argv] = this.argv; | ||
const [id, ...argv] = this.argv; | ||
this.parse(Object.assign({ strict: false, '--': false }, this.ctor)); | ||
if (!this.config.findCommand(id)) { | ||
let topic = this.config.findTopic(id); | ||
const topic = this.config.findTopic(id); | ||
if (topic) | ||
@@ -32,3 +32,3 @@ return this._help(); | ||
return true; | ||
for (let arg of this.argv) { | ||
for (const arg of this.argv) { | ||
if (arg === '--help') | ||
@@ -35,0 +35,0 @@ return true; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function compact(a) { | ||
return a.filter((a) => !!a); | ||
return a.filter((a) => Boolean(a)); | ||
} | ||
@@ -9,3 +9,3 @@ exports.compact = compact; | ||
return arr.filter((a, i) => { | ||
let aVal = fn(a); | ||
const aVal = fn(a); | ||
return !arr.find((b, j) => j > i && fn(b) === aVal); | ||
@@ -22,3 +22,3 @@ }); | ||
return 0; | ||
let diff = compare(a[0], b[0]); | ||
const diff = compare(a[0], b[0]); | ||
if (diff !== 0) | ||
@@ -25,0 +25,0 @@ return diff; |
{ | ||
"name": "@oclif/command", | ||
"description": "oclif base command", | ||
"version": "1.5.19", | ||
"version": "1.5.20", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -17,3 +17,2 @@ "bugs": "https://github.com/oclif/command/issues", | ||
"@oclif/plugin-plugins": "^1.7.7", | ||
"@oclif/tslint": "^3.1.1", | ||
"@types/chai": "^4.1.7", | ||
@@ -26,2 +25,5 @@ "@types/mocha": "^5.2.6", | ||
"conventional-changelog-cli": "^2.0.12", | ||
"eslint": "^6.6.0", | ||
"eslint-config-oclif": "^3.1.0", | ||
"eslint-config-oclif-typescript": "^0.1.0", | ||
"fancy-test": "^1.4.3", | ||
@@ -31,3 +33,2 @@ "globby": "^9.0.0", | ||
"ts-node": "^8.0.3", | ||
"tslint": "^5.14.0", | ||
"typescript": "^3.3.3333" | ||
@@ -61,9 +62,10 @@ }, | ||
"build": "rm -rf lib && tsc", | ||
"lint": "tsc -p test --noEmit && tslint -p test -t stylish", | ||
"posttest": "yarn run lint", | ||
"lint": "eslint . --ext .ts --config .eslintrc", | ||
"posttest": "yarn lint", | ||
"prepublishOnly": "yarn run build", | ||
"test": "mocha --forbid-only \"test/**/*.test.ts\"", | ||
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md" | ||
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md", | ||
"pretest": "tsc -p test --noEmit" | ||
}, | ||
"types": "lib/index.d.ts" | ||
} |
52253
467
16