Skip to content

Commit fb87809

Browse files
authored
replace deprecated optimist with yargs (#85)
* replace deprecated optimist with yargs * add github actions * remove node 12 * add package-lock.json
1 parent ee4654e commit fb87809

File tree

5 files changed

+7253
-46
lines changed

5 files changed

+7253
-46
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node: ['14', '16', '18']
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v2
14+
with:
15+
node-version: ${{ matrix.node }}
16+
- run: npm ci
17+
- run: sudo apt-get install xvfb
18+
- run: xvfb-run --auto-servernum npm test

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin/run.js

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,60 @@
11
#!/usr/bin/env node
22

33
var run = require('..');
4-
var optimist = require('optimist');
4+
var yargs = require('yargs/yargs');
5+
var { hideBin } = require('yargs/helpers');
56
var spawn = require('child_process').spawn;
67

7-
var argv = optimist
8+
var argv = yargs(hideBin(process.argv))
89
.usage('Pipe a browserify stream into this.\nbrowserify [opts] [files] | $0 [opts]')
910

10-
.describe('wait', 'Timeout for tap-finished')
11-
.alias('w', 'wait')
12-
13-
.describe('port', 'Wait to be opened by a browser on that port')
14-
.alias('p', 'port')
15-
16-
.describe('static', 'Serve static files from this directory')
17-
.alias('s', 'static')
18-
19-
.describe('browser', 'Browser to use. ' +
20-
'Always available: electron. ' +
21-
'Available if installed: chrome, firefox, ie, phantom, safari')
22-
.alias('b', 'browser')
23-
.default('browser', 'electron')
24-
25-
.describe('render', 'Command to pipe tap output to for custom rendering')
26-
.alias('r', 'render')
27-
28-
.describe('keep-open', 'Leave the browser open for debugging after running tests')
29-
.alias('k', 'keep-open')
30-
.alias('keepOpen', 'keep-open')
31-
32-
.describe('node', 'Enable nodejs integration for electron')
33-
.alias('n', 'integration')
34-
.alias('node-integration', 'node')
35-
.alias('nodeIntegration', 'node')
36-
37-
.describe('sandbox', 'Enable electron sandbox')
38-
.boolean('sandbox')
39-
.default('sandbox', true)
40-
41-
.describe('basedir', 'Set this if you need to require node modules in node mode')
42-
43-
.describe('help', 'Print usage instructions')
44-
.alias('h', 'help')
45-
46-
.argv;
47-
48-
if (argv.help) {
49-
return optimist.showHelp();
50-
}
11+
.option('wait', {
12+
alias: 'w',
13+
type: 'number',
14+
description: 'Timeout for tap-finished'
15+
})
16+
.option('port', {
17+
alias: 'p',
18+
type: 'number',
19+
description: 'Wait to be opened by a browser on that port'
20+
})
21+
.option('static', {
22+
alias: 's',
23+
type: 'string',
24+
description: 'Serve static files from this directory'
25+
})
26+
.option('browser', {
27+
alias: 'b',
28+
type: 'string',
29+
default: 'electron',
30+
description: 'Browser to use. ' +
31+
'Always available: electron. ' +
32+
'Available if installed: chrome, firefox, ie, phantom, safari'
33+
})
34+
.option('render', {
35+
alias: 'r',
36+
type: 'string',
37+
description: 'Command to pipe tap output to for custom rendering'
38+
})
39+
.option('keep-open', {
40+
alias: ['k', 'keepOpen'],
41+
type: 'boolean',
42+
description: 'Leave the browser open for debugging after running tests'
43+
})
44+
.option('node', {
45+
alias: ['n', 'node-integration', 'nodeIntegration'],
46+
type: 'boolean',
47+
description: 'Enable nodejs integration for electron'
48+
})
49+
.option('sandbox', {
50+
type: 'boolean',
51+
default: true,
52+
description: 'Enable electron sandbox'
53+
})
54+
.option('basedir', {
55+
description: 'Set this if you need to require node modules in node mode'
56+
})
57+
.parse();
5158

5259
var runner = run(argv);
5360

0 commit comments

Comments
 (0)