-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtasktool.js
50 lines (40 loc) · 1.39 KB
/
tasktool.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
// task tool for developing and compile examples and any subproject
// for development use with: npm run general PROJECT_NAME FOLDER_NAME
// e.j. npm run general playground examples
// for compile use with: npm run general PROJECT_NAME FOLDER_NAME
// e.j. npm run general-compile playground examples
// NOTE: by default FOLDER_NAME is examples, this allows to do that: npm run general playground
// TODO: document examples
var spawn = require('child_process').spawn
var option = process.argv[2]
var path = process.argv[3] || 'examples'
process.env.OPTION = option
process.env.OPTION_PATH = path
var cmd
if (process.env.NODE_ENV.trim() == 'development') {
console.log('Development server for ' + path + '/' + option + ' launched ...')
cmd = spawn('node', [
'node_modules/webpack-dev-server/bin/webpack-dev-server.js',
'--config', 'webpack/generalDevServer.config.js',
'--progress'
])
} else {
console.log('Compiler for ' + path + '/' + option + ' launched ...')
cmd = spawn('node', [
'node_modules/webpack/bin/webpack.js',
'--config', 'webpack/generalDist.config.js',
'--progress'
])
}
cmd.stdout.on('data', function (data) {
console.log(data + '')
})
cmd.stderr.on('data', function (data) {
console.log(data + '')
})
cmd.stderr.on('error', function (data) {
console.log(data + '')
})
cmd.on('exit', function (code) {
console.log('child process exited with code ' + code)
})