wirejs-scripts 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.js +19 -20
- package/configs/webpack.config.js +1 -6
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const process = require('process');
|
|
4
|
-
const child_process = require('child_process');
|
|
5
4
|
const rimraf = require('rimraf');
|
|
6
5
|
const fs = require('fs');
|
|
7
6
|
const path = require('path');
|
|
@@ -12,25 +11,9 @@ const WebpackDevServer = require('webpack-dev-server');
|
|
|
12
11
|
|
|
13
12
|
const CWD = process.cwd();
|
|
14
13
|
const webpackConfig = webpackConfigure(process.env, process.argv);
|
|
15
|
-
const [
|
|
14
|
+
const [_nodeBinPath, _scriptPath, action] = process.argv;
|
|
16
15
|
const processes = [];
|
|
17
16
|
|
|
18
|
-
async function exec(cmd) {
|
|
19
|
-
console.log('exec', cmd);
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
let proc;
|
|
22
|
-
proc = child_process.exec(cmd, (error, stdout, stderr) => {
|
|
23
|
-
processes.splice(processes.indexOf(proc), 1);
|
|
24
|
-
if (error || stderr) {
|
|
25
|
-
reject({ error, stderr });
|
|
26
|
-
} else {
|
|
27
|
-
resolve(stdout);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
processes.push(proc);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
17
|
async function compile(watch = false) {
|
|
35
18
|
const stats = await new Promise((resolve, reject) => {
|
|
36
19
|
if (watch) {
|
|
@@ -53,11 +36,16 @@ async function compile(watch = false) {
|
|
|
53
36
|
|
|
54
37
|
resolve({});
|
|
55
38
|
} else {
|
|
39
|
+
console.log('wirejs instantiating webpack compiler');
|
|
56
40
|
compiler = webpack(webpackConfig);
|
|
57
41
|
compiler.run((err, res) => {
|
|
42
|
+
console.log('wirejs invoking webpack compiler');
|
|
58
43
|
if (err) {
|
|
44
|
+
console.error('wirejs webpack compiler failed');
|
|
45
|
+
console.error(err);
|
|
59
46
|
reject(err);
|
|
60
47
|
} else {
|
|
48
|
+
console.error('wirejs webpack compiler succeeded');
|
|
61
49
|
resolve(res);
|
|
62
50
|
}
|
|
63
51
|
});
|
|
@@ -65,7 +53,7 @@ async function compile(watch = false) {
|
|
|
65
53
|
});
|
|
66
54
|
|
|
67
55
|
if (stats?.compilation?.errors?.length > 0) {
|
|
68
|
-
console.log(stats.compilation.errors);
|
|
56
|
+
console.log('wirejs compilation errors', stats.compilation.errors);
|
|
69
57
|
throw new Error('Build failed.');
|
|
70
58
|
}
|
|
71
59
|
|
|
@@ -74,16 +62,26 @@ async function compile(watch = false) {
|
|
|
74
62
|
|
|
75
63
|
const engine = {
|
|
76
64
|
async build({ watch = false } = {}) {
|
|
65
|
+
console.log('wirejs build starting');
|
|
66
|
+
|
|
77
67
|
rimraf.sync('dist');
|
|
68
|
+
console.log('wirejs cleared old dist folder');
|
|
69
|
+
|
|
78
70
|
fs.mkdirSync('dist');
|
|
71
|
+
console.log('wirejs recreated dist folder');
|
|
72
|
+
|
|
79
73
|
try {
|
|
74
|
+
|
|
80
75
|
await compile(watch);
|
|
76
|
+
console.log('wirejs finished compile');
|
|
81
77
|
} catch (err) {
|
|
82
78
|
console.log(err);
|
|
83
79
|
}
|
|
80
|
+
console.log('wirejs build finished')
|
|
84
81
|
},
|
|
85
82
|
|
|
86
83
|
async start() {
|
|
84
|
+
console.log('wirejs starting')
|
|
87
85
|
this.build({ watch: true });
|
|
88
86
|
|
|
89
87
|
await new Promise(resolve => {
|
|
@@ -97,6 +95,7 @@ const engine = {
|
|
|
97
95
|
});
|
|
98
96
|
|
|
99
97
|
// explicit exit forces lingering child processes to die.
|
|
98
|
+
console.log('wirejs stopping')
|
|
100
99
|
process.exit();
|
|
101
100
|
}
|
|
102
101
|
|
|
@@ -109,4 +108,4 @@ if (typeof engine[action] === 'function') {
|
|
|
109
108
|
});
|
|
110
109
|
} else {
|
|
111
110
|
console.error(`Invalid wirejs-scripts action: ${action}`);
|
|
112
|
-
}
|
|
111
|
+
}
|
|
@@ -285,12 +285,7 @@ module.exports = (env, argv) => {
|
|
|
285
285
|
}
|
|
286
286
|
},
|
|
287
287
|
{
|
|
288
|
-
test: /\.md$/,
|
|
289
|
-
use: "raw-loader",
|
|
290
|
-
// use: path.resolve(__dirname, '../node_modules/raw-loader')
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
test: /\.tpl$/,
|
|
288
|
+
test: /\.(md|tpl)$/,
|
|
294
289
|
use: "raw-loader",
|
|
295
290
|
// use: path.resolve(__dirname, '../node_modules/raw-loader')
|
|
296
291
|
},
|