mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
|
|
require('@babel/register');
|
|
|
|
const argv = require('minimist')(process.argv.slice(2));
|
|
const rollup = require('rollup');
|
|
|
|
const config = require('../rollup/rollup.config').default;
|
|
|
|
const MANIFEST_NAME = 'fx_cast_bridge.json';
|
|
|
|
async function build() {
|
|
const {path: executablePath, platform, ...configOptions} = argv;
|
|
|
|
const {output: bundleOutputs, ...bundleOptions} = config(configOptions);
|
|
const bundle = await rollup.rollup(bundleOptions);
|
|
|
|
for (const output of bundleOutputs) {
|
|
await bundle.write(output);
|
|
fs.chmodSync(output.file, '755');
|
|
}
|
|
|
|
const targetPlatform = platform || os.type();
|
|
const launcherExt = targetPlatform.toLowerCase().startsWith('win')
|
|
? 'bat'
|
|
: 'sh';
|
|
const launcherName = `launcher.${launcherExt}`;
|
|
const launcherPath = path.join(__dirname, '../../dist', launcherName);
|
|
|
|
fs.copyFileSync(path.join(`src`, launcherName), launcherPath);
|
|
|
|
const manifest = {
|
|
...(JSON.parse(fs.readFileSync(`src/${MANIFEST_NAME}`, 'utf8')))
|
|
, path: (executablePath || path.resolve(launcherPath))
|
|
};
|
|
|
|
fs.writeFileSync(
|
|
path.join('../dist/app', MANIFEST_NAME)
|
|
, JSON.stringify(manifest, null, 4)
|
|
);
|
|
}
|
|
|
|
build().catch(e => {
|
|
console.log("Build failed", e);
|
|
process.exit(1);
|
|
});
|