1
1
const { execSync } = require ( 'child_process' )
2
2
const path = require ( 'path' )
3
3
const fs = require ( 'fs' )
4
+ const process = require ( 'process' )
4
5
5
6
const buildDir = path . join ( process . cwd ( ) , 'build' )
6
7
const distDir = path . join ( process . cwd ( ) , 'dist' )
@@ -9,21 +10,26 @@ const buildIndexJs = path.join(buildDir, 'index.js')
9
10
const distIndexJs = path . join ( distDir , 'index.js' )
10
11
const distCleanupJs = path . join ( distDir , 'cleanup.js' )
11
12
13
+ var ncc = `./node_modules/.bin/ncc` ;
14
+ if ( process . platform === "win32" ) {
15
+ ncc = `.\\node_modules\\.bin\\ncc.cmd` ;
16
+ }
17
+
12
18
if ( ! fs . existsSync ( buildDir ) ) {
13
19
fs . mkdirSync ( buildDir )
14
20
}
15
21
16
22
// Build the main index.js file
17
23
console . log ( 'Building index.js...' )
18
- execSync ( `./node_modules/.bin/ ncc build index.js -q -o ${ buildDir } ` )
24
+ execSync ( `${ ncc } build index.js -q -o ${ buildDir } ` )
19
25
if ( fs . existsSync ( distIndexJs ) ) {
20
26
fs . unlinkSync ( distIndexJs )
21
27
}
22
28
fs . renameSync ( buildIndexJs , distIndexJs )
23
29
24
30
// Build the cleanup.js file
25
31
console . log ( 'Building cleanup.js...' )
26
- execSync ( `./node_modules/.bin/ ncc build cleanup.js -q -o ${ buildDir } ` )
32
+ execSync ( `${ ncc } build cleanup.js -q -o ${ buildDir } ` )
27
33
if ( fs . existsSync ( distCleanupJs ) ) {
28
34
fs . unlinkSync ( distCleanupJs )
29
35
}
0 commit comments