Switch from nexe to pkg build process (faster, works)
This commit is contained in:
parent
81543f3583
commit
122a0aa404
|
@ -0,0 +1,51 @@
|
|||
'use strict'
|
||||
|
||||
const { exec } = require('pkg')
|
||||
const execRaw = require('child_process').exec
|
||||
const os = require('os')
|
||||
const fs = require('fs-extra')
|
||||
const packageJson = require('./package.json')
|
||||
|
||||
const platform = os.platform()
|
||||
const arch = os.arch()
|
||||
|
||||
/**
|
||||
* Shells out to execute a command with async/await.
|
||||
* Async wrapper to exec module.
|
||||
*
|
||||
* @param {string} cmd Command to execute
|
||||
*
|
||||
* @returns {Promise} Promise containing the complete stdio
|
||||
**/
|
||||
async function shell_out (cmd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return execRaw(cmd, (err, stdio, stderr) => {
|
||||
if (err) return reject(err)
|
||||
return resolve(stdio)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
//exec(args) takes an array of command line arguments and returns a promise. For example:
|
||||
|
||||
if (!fs.existsSync(`./dist/${platform}_${arch}`)) {
|
||||
fs.mkdirSync(`./dist/${platform}_${arch}`)
|
||||
}
|
||||
|
||||
console.log(`Building v2f and saving in dist/${platform}_${arch}...`)
|
||||
console.time('v2f')
|
||||
exec([ 'v2f.js', '--target', 'node10', '--output', `./dist/${platform}_${arch}/v2f` ]).then(async (res) => {
|
||||
try {
|
||||
await shell_out(`zip -r ./dist/v2f_${platform}_${arch}_${packageJson.version}.zip ./dist/${platform}_${arch}/v2f`)
|
||||
console.log(`Compressed binary to dist/v2f_${platform}_${arch}_${packageJson.version}.zip`)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
process.exit(err)
|
||||
}
|
||||
|
||||
console.timeEnd('v2f')
|
||||
console.log('built')
|
||||
}).catch(err => {
|
||||
console.error(err)
|
||||
})
|
||||
// do something with app.exe, run, test, upload, deploy, etc
|
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
|
@ -5,28 +5,27 @@
|
|||
"main": "v2f.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "sh ./scripts/build.sh",
|
||||
"build": "node build.js",
|
||||
"compile": "./node_modules/.bin/tsc ./src/v2f.ts --outFile ./v2f.js --noImplicitAny --lib ES2017 --lib ES2016 -t ES2016",
|
||||
"docs": "./node_modules/.bin/jsdoc2md ./v2f.js > ./docs/Readme.md"
|
||||
},
|
||||
"author": "mmcwilliams",
|
||||
"license": "MIT",
|
||||
"nexe": {
|
||||
"output": "../video_to_page_nexe/v2f",
|
||||
"runtime": {
|
||||
"ignoreFlags": true,
|
||||
"framework": "nodejs",
|
||||
"version": "8.7.0"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"async": "^2.6.2",
|
||||
"commander": "^2.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^11.13.4",
|
||||
"fs-extra": "^8.1.0",
|
||||
"jsdoc-to-markdown": "^4.0.1",
|
||||
"nexe": "^3.1.0",
|
||||
"pkg": "^4.4.0",
|
||||
"typescript": "^3.4.3"
|
||||
},
|
||||
"pkg": {
|
||||
"scripts": [
|
||||
"./v2f.js",
|
||||
"./package.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue