Skip to content

Commit 0e863eb

Browse files
committed
Remove workaround for yargs/yargs#755
This was fixed in yargs 7.0.0 2 years ago, but the issue had not been closed. Signed-off-by: Kevin Locke <[email protected]>
1 parent 2df6269 commit 0e863eb

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

bin/cmd.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,6 @@ const Yargs = require('yargs/yargs');
1212
const packageJson = require('../package.json');
1313
const modulename = require('..');
1414

15-
/** Calls <code>yargs.parse</code> and passes any thrown errors to the callback.
16-
* Workaround for https://github.com/yargs/yargs/issues/755
17-
* @private
18-
*/
19-
function parseYargs(yargs, args, callback) {
20-
// Since yargs doesn't nextTick its callback, this function must be careful
21-
// that exceptions thrown from callback (which propagate through yargs.parse)
22-
// are not caught and passed to a second invocation of callback.
23-
let called = false;
24-
try {
25-
yargs.parse(args, function(...cbargs) {
26-
called = true;
27-
return callback.apply(this, cbargs);
28-
});
29-
} catch (err) {
30-
if (called) {
31-
// err was thrown after or by callback. Let it propagate.
32-
throw err;
33-
} else {
34-
callback(err);
35-
}
36-
}
37-
}
38-
3915
/** Options for command entry points.
4016
*
4117
* @typedef {{
@@ -114,7 +90,7 @@ function modulenameCmd(args, options, callback) {
11490
.version(`${packageJson.name} ${packageJson.version}`)
11591
.alias('version', 'V')
11692
.strict();
117-
parseYargs(yargs, args, (err, argOpts, output) => {
93+
yargs.parse(args, (err, argOpts, output) => {
11894
if (err) {
11995
if (output) {
12096
options.stderr.write(`${output}\n`);

0 commit comments

Comments
 (0)