-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepack.js
44 lines (37 loc) · 871 Bytes
/
prepack.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
var { spawn } = require('child_process');
var os = require('os');
var manifest = require('./plugin-manifest.json');
var { moduleSupport } = manifest;
function runPrePack() {
let npm = os.platform() === 'win32' ? 'npm.cmd' : 'npm';
return new Promise((resolve, reject) => {
let execution = spawn(npm, ['run', 'build']);
let error = '';
execution.stdout.on('data', data => {
console.log(data.toString());
});
execution.stderr.on('data', data => {
error += data.toString().trim();
});
execution.on('error', error => {
reject(error);
});
execution.on('close', code => {
if (error) {
reject(error);
}
resolve();
});
});
}
if (moduleSupport) {
runPrePack()
.then(() => {
process.exit();
})
.catch(err => {
throw err;
});
} else {
process.exit();
}