Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit 19ff4de

Browse files
committed
fix: return types of error/exit methods
1 parent 30eabf0 commit 19ff4de

File tree

4 files changed

+41
-31
lines changed

4 files changed

+41
-31
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@
1111
]
1212
},
1313
"dependencies": {
14-
"@oclif/errors": "^1.0.8",
14+
"@oclif/errors": "^1.0.9",
1515
"@oclif/parser": "^3.3.3",
1616
"debug": "^3.1.0",
1717
"semver": "^5.5.0"
1818
},
1919
"devDependencies": {
2020
"@oclif/config": "^1.6.17",
2121
"@oclif/plugin-help": "^1.2.10",
22-
"@oclif/plugin-plugins": "^1.1.6",
22+
"@oclif/plugin-plugins": "^1.1.8",
2323
"@oclif/tslint": "^1.1.0",
2424
"@types/chai": "^4.1.3",
2525
"@types/mocha": "^5.2.0",
26-
"@types/node": "^10.0.3",
26+
"@types/node": "^10.0.4",
2727
"@types/semver": "^5.5.0",
2828
"chai": "^4.1.2",
2929
"fancy-test": "^1.0.6",
3030
"globby": "^8.0.1",
3131
"mocha": "^5.1.1",
32-
"ts-node": "^6.0.2",
33-
"tslint": "^5.9.1",
32+
"ts-node": "^6.0.3",
33+
"tslint": "^5.10.0",
3434
"typescript": "^2.8.3"
3535
},
3636
"engines": {

src/command.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ export default abstract class Command {
6565
}
6666
}
6767

68-
exit(code = 0) { Errors.exit(code) }
68+
exit(code = 0) { return Errors.exit(code) }
6969
warn(input: string | Error) { Errors.warn(input) }
7070
error(input: string | Error, options: {code?: string, exit?: number} = {}) {
71-
Errors.error(input, options)
71+
return Errors.error(input, options)
7272
}
7373
log(message = '', ...args: any[]) {
7474
// tslint:disable-next-line strict-type-predicates
@@ -101,9 +101,9 @@ export default abstract class Command {
101101
protected async catch(err: any) {
102102
if (!err.message) throw err
103103
if (err.message.match(/Unexpected arguments?: (-h|--help|help)(,|\n)/)) {
104-
this._help()
104+
return this._help()
105105
} else if (err.message.match(/Unexpected arguments?: (-v|--version|version)(,|\n)/)) {
106-
this._version()
106+
return this._version()
107107
} else {
108108
try {
109109
const {cli} = require('cli-ux')
@@ -126,7 +126,7 @@ export default abstract class Command {
126126
let title = this.ctor.description && help.render(this.ctor.description).split('\n')[0]
127127
if (title) this.log(title + '\n')
128128
this.log(help.command(Config.Command.toCached(this.ctor as any as Config.Command.Class)))
129-
this.exit(0)
129+
return this.exit(0)
130130
}
131131

132132
protected _helpOverride(): boolean {
@@ -139,6 +139,6 @@ export default abstract class Command {
139139

140140
protected _version() {
141141
this.log(this.config.userAgent)
142-
this.exit(0)
142+
return this.exit(0)
143143
}
144144
}

src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class Main extends Command {
1111
async init() {
1212
let [id, ...argv] = this.argv
1313
await this.config.runHook('init', {id, argv})
14-
await super.init()
14+
return super.init()
1515
}
1616

1717
async run() {
@@ -39,7 +39,7 @@ export class Main extends Command {
3939
const HHelp: typeof Help = require('@oclif/plugin-help').default
4040
const help = new HHelp(this.config)
4141
help.showHelp(this.argv)
42-
this.exit(0)
42+
return this.exit(0)
4343
}
4444
}
4545

yarn.lock

+28-18
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
call-me-maybe "^1.0.1"
3535
glob-to-regexp "^0.3.0"
3636

37-
"@oclif/command@^1.4.18", "@oclif/command@^1.4.20":
37+
"@oclif/command@^1.4.20":
3838
version "1.4.20"
3939
resolved "https://registry.yarnpkg.com/@oclif/command/-/command-1.4.20.tgz#7368c9c9f7f596fc8efffd7ec89118feed5203d8"
4040
dependencies:
@@ -59,6 +59,16 @@
5959
strip-ansi "^4.0.0"
6060
wrap-ansi "^3.0.1"
6161

62+
"@oclif/errors@^1.0.9":
63+
version "1.0.9"
64+
resolved "https://registry.yarnpkg.com/@oclif/errors/-/errors-1.0.9.tgz#6fe3afd8e7683c436df63674550899adec10c81c"
65+
dependencies:
66+
clean-stack "^1.3.0"
67+
fs-extra "^6.0.0"
68+
indent-string "^3.2.0"
69+
strip-ansi "^4.0.0"
70+
wrap-ansi "^3.0.1"
71+
6272
"@oclif/linewrap@^1.0.0":
6373
version "1.0.0"
6474
resolved "https://registry.yarnpkg.com/@oclif/linewrap/-/linewrap-1.0.0.tgz#aedcb64b479d4db7be24196384897b5000901d91"
@@ -82,18 +92,18 @@
8292
widest-line "^2.0.0"
8393
wrap-ansi "^3.0.1"
8494

85-
"@oclif/plugin-plugins@^1.1.6":
86-
version "1.1.6"
87-
resolved "https://registry.yarnpkg.com/@oclif/plugin-plugins/-/plugin-plugins-1.1.6.tgz#4e2e89297bfe5e66acbb2b579a3a2904a6c3aab7"
95+
"@oclif/plugin-plugins@^1.1.8":
96+
version "1.1.8"
97+
resolved "https://registry.yarnpkg.com/@oclif/plugin-plugins/-/plugin-plugins-1.1.8.tgz#57e3b00039fc0952304f8fa49532f8ff9c1ceaff"
8898
dependencies:
8999
"@heroku-cli/color" "^1.1.3"
90-
"@oclif/command" "^1.4.18"
100+
"@oclif/command" "^1.4.20"
91101
chalk "^2.4.1"
92102
cli-ux "^3.4.1"
93103
debug "^3.1.0"
94104
fs-extra "^6.0.0"
95105
http-call "^5.1.1"
96-
load-json-file "^4.0.0"
106+
load-json-file "^5.0.0"
97107
npm-run-path "^2.0.2"
98108
semver "^5.5.0"
99109
tslib "^1.9.0"
@@ -117,9 +127,9 @@
117127
version "5.2.0"
118128
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.0.tgz#b3c8e69f038835db1a7fdc0b3d879fc50506e29e"
119129

120-
"@types/node@^10.0.3":
121-
version "10.0.3"
122-
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.0.3.tgz#1f89840c7aac2406cc43a2ecad98fc02a8e130e4"
130+
"@types/node@^10.0.4":
131+
version "10.0.4"
132+
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.0.4.tgz#130598ee56e9a1210a53f557d64935571f05390d"
123133

124134
"@types/semver@^5.5.0":
125135
version "5.5.0"
@@ -886,9 +896,9 @@ kind-of@^6.0.0, kind-of@^6.0.2:
886896
version "6.0.2"
887897
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"
888898

889-
load-json-file@^4.0.0:
890-
version "4.0.0"
891-
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b"
899+
load-json-file@^5.0.0:
900+
version "5.0.0"
901+
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-5.0.0.tgz#5b5ef7cb6e1e337408e02fe01fe679ccc0cd18d5"
892902
dependencies:
893903
graceful-fs "^4.1.2"
894904
parse-json "^4.0.0"
@@ -1337,9 +1347,9 @@ to-regex@^3.0.1, to-regex@^3.0.2:
13371347
regex-not "^1.0.2"
13381348
safe-regex "^1.1.0"
13391349

1340-
ts-node@^6.0.2:
1341-
version "6.0.2"
1342-
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-6.0.2.tgz#e132d530e53173bc6a8c21ea65f64d8b47bc573e"
1350+
ts-node@^6.0.3:
1351+
version "6.0.3"
1352+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-6.0.3.tgz#28bf74bcad134fad17f7469dad04638ece03f0f4"
13431353
dependencies:
13441354
arrify "^1.0.0"
13451355
chalk "^2.3.0"
@@ -1384,9 +1394,9 @@ tslint-xo@^0.7.0:
13841394
tslint-eslint-rules "^5.1.0"
13851395
tslint-microsoft-contrib "^5.0.2"
13861396

1387-
tslint@^5.9.1:
1388-
version "5.9.1"
1389-
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.9.1.tgz#1255f87a3ff57eb0b0e1f0e610a8b4748046c9ae"
1397+
tslint@^5.10.0:
1398+
version "5.10.0"
1399+
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.10.0.tgz#11e26bccb88afa02dd0d9956cae3d4540b5f54c3"
13901400
dependencies:
13911401
babel-code-frame "^6.22.0"
13921402
builtin-modules "^1.1.1"

0 commit comments

Comments
 (0)