-
Notifications
You must be signed in to change notification settings - Fork 122
/
node.js
executable file
·65 lines (55 loc) · 1.47 KB
/
node.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env node
var wordwrap = require('wordwrap')
var inquirer = require('inquirer')
var minimist = require('minimist')
var opener = require('opener')
var chalk = require('chalk')
console.error()
console.error(chalk.yellow(' =============================='))
console.error(chalk.yellow(' = ~~~~~ ')+'webgl-workshop'+chalk.yellow(' ~~~~~ ='))
console.error(chalk.yellow(' =============================='))
console.error()
var argv = minimist(process.argv.slice(2), {
boolean: ['o', 'y']
, default: { o: true }
, alias: {
o: 'open'
, y: 'yes'
}
})
if (argv.yes) {
boot()
} else {
prompt()
}
function prompt() {
inquirer.prompt([{
'type': 'confirm'
, 'name': 'ok'
, 'default': true
, 'message': wordwrap(4, 80)(
"We're about to populate this directory with some code for you to " +
"use for your answers. If they've already been created then don't worry, " +
"they won't be replaced. Continue?"
).replace(/^\s+/, '')
}], function(result) {
if (!result.ok) return process.exit(1)
console.error()
boot()
})
}
function boot() {
require('@workshop/server')({}, function(err, address) {
if (err) throw err
if (argv.open) {
console.error('Done! Booting up the workshop in your browser in just a second...')
}
console.error('Workshop running on: '+chalk.blue(address))
console.error()
if (argv.open) {
setTimeout(function() {
opener(address)
}, 1000)
}
})
}