Skip to content

Commit 5fedeb5

Browse files
mpdudeshaunco
andcommitted
Fix scripts/build.js to work on Windows
Suggested by @shaunco in #38. Co-authored-by: Shaun Cooley <[email protected]>
1 parent 780d0ee commit 5fedeb5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/build.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { execSync } = require('child_process')
22
const path = require('path')
33
const fs = require('fs')
4+
const process = require('process')
45

56
const buildDir = path.join(process.cwd(), 'build')
67
const distDir = path.join(process.cwd(), 'dist')
@@ -9,21 +10,26 @@ const buildIndexJs = path.join(buildDir, 'index.js')
910
const distIndexJs = path.join(distDir, 'index.js')
1011
const distCleanupJs = path.join(distDir, 'cleanup.js')
1112

13+
var ncc = `./node_modules/.bin/ncc`;
14+
if (process.platform === "win32") {
15+
ncc = `.\\node_modules\\.bin\\ncc.cmd`;
16+
}
17+
1218
if (!fs.existsSync(buildDir)) {
1319
fs.mkdirSync(buildDir)
1420
}
1521

1622
// Build the main index.js file
1723
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}`)
1925
if (fs.existsSync(distIndexJs)) {
2026
fs.unlinkSync(distIndexJs)
2127
}
2228
fs.renameSync(buildIndexJs, distIndexJs)
2329

2430
// Build the cleanup.js file
2531
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}`)
2733
if (fs.existsSync(distCleanupJs)) {
2834
fs.unlinkSync(distCleanupJs)
2935
}

0 commit comments

Comments
 (0)