-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbin.js
More file actions
executable file
·63 lines (55 loc) · 1.42 KB
/
bin.js
File metadata and controls
executable file
·63 lines (55 loc) · 1.42 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env node
var minimist = require('minimist')
var chalk = require('chalk')
var dedent = require('dedent')
var assert = require('assert')
var app = require('./server')
var argv = minimist(process.argv.slice(2), {
alias: {
'help': 'h',
'library': 'l',
'open': 'o',
'port': 'p',
'version': 'v'
},
default: {
port: process.env.PORT || 8080
},
boolean: [
'help',
'library',
'open',
'version'
]
})
if (argv.help) {
console.log(dedent`
\n${chalk.dim('usage')}
${chalk.yellow.bold('nanoconstruct')} [opts] <entry>
${chalk.dim('options')}
--help, -h show this help text
--library, -l use all the files from a library
--open, -o open the page in the browser
--port, -p server port
--version, -v print version
${chalk.dim('examples')}
${chalk.bold('start server')}
nanoconstruct example.js
${chalk.bold('start server on port 3000 and open it')}
nanoconstruct example.js -p 3000 -o
${chalk.bold('start server with library mode')}
nanoconstruct components --library
`, '\n')
process.exit(0)
}
if (argv.version) {
console.log(require('./package.json').version)
process.exit(0)
}
var entry = argv._[0]
assert(entry, 'nanoconstruct: entry path should be supplied')
app(entry, {
port: argv.port,
open: argv.open,
library: argv.library
})