mirror of
https://github.com/webfactory/ssh-agent.git
synced 2024-11-24 01:58:01 +00:00
Fix scripts/build.js to work on Windows
Suggested by @shaunco in #38. Co-authored-by: Shaun Cooley <scooley@mapped.com>
This commit is contained in:
parent
780d0ee9a3
commit
5fedeb584e
1 changed files with 8 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
const { execSync } = require('child_process')
|
const { execSync } = require('child_process')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
const process = require('process')
|
||||||
|
|
||||||
const buildDir = path.join(process.cwd(), 'build')
|
const buildDir = path.join(process.cwd(), 'build')
|
||||||
const distDir = path.join(process.cwd(), 'dist')
|
const distDir = path.join(process.cwd(), 'dist')
|
||||||
|
@ -9,13 +10,18 @@ const buildIndexJs = path.join(buildDir, 'index.js')
|
||||||
const distIndexJs = path.join(distDir, 'index.js')
|
const distIndexJs = path.join(distDir, 'index.js')
|
||||||
const distCleanupJs = path.join(distDir, 'cleanup.js')
|
const distCleanupJs = path.join(distDir, 'cleanup.js')
|
||||||
|
|
||||||
|
var ncc = `./node_modules/.bin/ncc`;
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
ncc = `.\\node_modules\\.bin\\ncc.cmd`;
|
||||||
|
}
|
||||||
|
|
||||||
if (!fs.existsSync(buildDir)) {
|
if (!fs.existsSync(buildDir)) {
|
||||||
fs.mkdirSync(buildDir)
|
fs.mkdirSync(buildDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the main index.js file
|
// Build the main index.js file
|
||||||
console.log('Building index.js...')
|
console.log('Building index.js...')
|
||||||
execSync(`./node_modules/.bin/ncc build index.js -q -o ${buildDir}`)
|
execSync(`${ncc} build index.js -q -o ${buildDir}`)
|
||||||
if (fs.existsSync(distIndexJs)) {
|
if (fs.existsSync(distIndexJs)) {
|
||||||
fs.unlinkSync(distIndexJs)
|
fs.unlinkSync(distIndexJs)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +29,7 @@ fs.renameSync(buildIndexJs, distIndexJs)
|
||||||
|
|
||||||
// Build the cleanup.js file
|
// Build the cleanup.js file
|
||||||
console.log('Building cleanup.js...')
|
console.log('Building cleanup.js...')
|
||||||
execSync(`./node_modules/.bin/ncc build cleanup.js -q -o ${buildDir}`)
|
execSync(`${ncc} build cleanup.js -q -o ${buildDir}`)
|
||||||
if (fs.existsSync(distCleanupJs)) {
|
if (fs.existsSync(distCleanupJs)) {
|
||||||
fs.unlinkSync(distCleanupJs)
|
fs.unlinkSync(distCleanupJs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue