forked from juliangruber/browser-run
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.js
executable file
·50 lines (36 loc) · 1.33 KB
/
bin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
var run = require('..');
var optimist = require('optimist');
var argv = optimist
.usage(
'Run JavaScript in a browser.\n' +
'Write code to stdin and receive console output on stdout.\n' +
'Usage: $0 [OPTIONS]'
)
.describe('browser', 'Browser to use. '
+ 'Always available: electron. '
+ 'Available if installed: '
+ 'chrome, firefox, ie, phantom, safari')
.alias('browser', 'b')
.default('browser', 'electron')
.describe('port', 'Starts listening on that port and waits for you to open a browser')
.alias('p', 'port')
.describe('static', 'Serve static assets from this directory')
.alias('s', 'static')
.describe('mock', 'Path to code to handle requests for mocking a dynamic back-end')
.alias('m', 'mock')
.describe('input', 'Input type. Defaults to \'javascript\', can be set to \'html\'.')
.alias('i', 'input')
.describe('node', 'Enable nodejs apis in electron')
.alias('n', 'node')
.describe('show', 'Show browser window if browser is electron')
.alias('w', 'show')
.describe('basedir', 'Set this if you need to require node modules in node mode')
.describe('help', 'Print help')
.alias('h', 'help')
.argv;
argv.nodeIntegration = argv['node-integration']
if (argv.help) return optimist.showHelp();
process.stdin
.pipe(run(argv))
.pipe(process.stdout);