Skip to content

Commit a2bd4da

Browse files
committed
chore: fix yargs regression
1 parent aba96cf commit a2bd4da

3 files changed

Lines changed: 1053 additions & 7977 deletions

File tree

lib/cli.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
11
'use strict'
22

3-
const { execute } = require('./core')
3+
const {execute} = require('./core')
44

5-
const { argv, showHelp } = require('yargs')
6-
.wrap(null) // specify no column limit (no right-align)
7-
.usage('Usage: $0 <command> [options]')
8-
.help('h')
9-
.alias('h', 'help')
10-
.version()
11-
.alias('v', 'version')
5+
const yargs = require('yargs/yargs')(process.argv.slice(2));
126

13-
.boolean('raw-input')
14-
.alias('x', 'raw-input')
15-
.describe('raw-input', 'Read input as a string')
7+
const {hideBin} = require('yargs/helpers');
8+
const argv = yargs.usage('Usage: $0 <command> [options]')
9+
.help('h')
10+
.alias('h', 'help')
11+
.version()
12+
.alias('v', 'version')
1613

17-
.boolean('json')
18-
.alias('j', 'json')
19-
.describe('json', 'Force JSON output')
14+
.boolean('raw-input')
15+
.alias('x', 'raw-input')
16+
.describe('raw-input', 'Read input as a string')
2017

21-
.boolean('color')
22-
.alias('C', 'color')
23-
.describe('color', 'Colorize JSON (--color=false to disable it)')
18+
.boolean('json')
19+
.alias('j', 'json')
20+
.describe('json', 'Force JSON output')
21+
22+
.boolean('color')
23+
.alias('C', 'color')
24+
.describe('color', 'Colorize JSON (--color=false to disable it)')
25+
26+
.describe('require', 'require the given module')
27+
.alias('r', 'require')
28+
.argv;
2429

25-
.describe('require', 'require the given module')
26-
.alias('r', 'require');
2730

2831
if (process.stdin.isTTY) {
29-
showHelp();
30-
process.exit(0);
32+
yargs.showHelp();
33+
//showHelp();
34+
//process.exit(0);
35+
36+
return;
3137
}
3238

33-
const options = Object.assign({}, argv, { transform: argv._[0] })
39+
const options = Object.assign({}, argv, {transform: argv._[0]})
3440
execute(process.stdin, options, (err, result) => {
35-
if (err) {
36-
console.error(err.message);
37-
process.exit(1);
38-
}
41+
if (err) {
42+
console.error(err.message);
43+
process.exit(1);
44+
}
3945

40-
console.log(result);
46+
console.log(result);
4147
})

0 commit comments

Comments
 (0)