Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var build = () => {
// Build
if (!cli.downloadOnly) {
builder
.build({
targets: builder.createTargets([targetOs]),
config: Object.assign(buildConfig, {
extraMetadata: cli.package
? Object.assign(cli.extraMetadata, { package: cli.package })
: cli.extraMetadata
})
})
.then(() => {
console.log("Done");
})
.catch(e => {
if (
e.message.indexOf("GitHub Personal Access Token is not set") !== -1
) {
console.log("Done");
process.exit(0);
} else {
//config.asar=false;
//prebuild serialport
config.beforeBuild=(args)=>new Promise((done,fail)=>{
// if (args.platform.nodeName=='darwin')//skip it
// return done();
var cmd = 'npm rebuild serialport-v4 --update-binary'
+ ' --target_platform='+args.platform.nodeName+' --target_arch='+args.arch
+ ' --runtime=electron --target='+electron_version
console.log('beforeBuild:',cmd);
exec(cmd,(err,stdout,stderr)=>err?fail(stderr):(console.log(stdout),done(stdout)))
});
//console.log(builder.createTargets(platforms,null,archs))
//if(0)
builder.build({
targets: builder.createTargets(platforms,null,archs),
config: config,
})
.then(() => {
// handle result
console.log('done')
})
.catch((error) => {
// handle error
console.error(error)
})
}
if (this.$.env.options.mac) {
targets.push(Platform.MAC);
}
if (targets.length === 0) {
if (this.$.env.os.isWindows) {
targets.push(Platform.WINDOWS);
} else if (this.$.env.os.isLinux) {
targets.push(Platform.LINUX);
} else {
targets.push(Platform.MAC);
}
}
const target = createTargets(targets, null, arch);
try {
await build({
targets: target,
devMetadata: {
directories: {
app: this.$.env.paths.electronApp.root,
output: path.join(this.$.env.options.output, this.$.env.paths.installerDir)
},
build: settings.builderOptions
}
});
} catch (e) {
this.log.error('error while building installer: ', e);
} finally {
// Move node_modules back.
const targets = [];
if (argv.mac) {
targets.push(builder.Platform.MAC);
}
if (argv.win) {
targets.push(builder.Platform.WINDOWS);
}
if (argv.linux) {
targets.push(builder.Platform.LINUX);
}
builder.build({
targets: builder.createTargets(targets, null, 'all'),
devMetadata: {
build: {
afterPack(params) {
return Q.try(() => {
console.log('Copying LICENSE, AUTHORS, README...');
shell.cp(
path.join(ROOT_FOLDER, 'LICENSE'),
params.appOutDir
);
shell.cp(
path.join(ROOT_FOLDER, 'AUTHORS'),
params.appOutDir
);
});
fs.writeFileSync(
path.join(__dirname, `../dist_${type}`, 'app', 'package.json'),
JSON.stringify(appPackageJson, null, 2),
'utf-8'
);
const targets = [];
if (options.mac) targets.push(builder.Platform.MAC);
if (options.win) targets.push(builder.Platform.WINDOWS);
if (options.linux) targets.push(builder.Platform.LINUX);
builder
.build({
targets: builder.createTargets(targets, null, 'all'),
projectDir: path.join(__dirname, `../dist_${type}`, 'app'),
publish: 'never',
config: {
afterPack(params) {
return Q.try(() => {
shell.cp(
[
path.join(__dirname, '..', 'LICENSE'),
path.join(__dirname, '..', 'README.md'),
path.join(__dirname, '..', 'AUTHORS')
],
params.appOutDir
);
});
}
}
function startBuild() {
let target = process.env.p === 'WIN' ? electronBuilder.Platform.WINDOWS : electronBuilder.Platform.MAC;
electronBuilder.build({
targets: electronBuilder.createTargets([
target
], null, 'all'),
projectDir: path.join(__dirname, './app'),
publish: 'never'
}).then((files)=>{
writeSha256(files);
}).catch(err => {
throw new Error(err);
});
}
}
}
});
fs.writeFileSync(
path.join(__dirname, `../dist_${type}`, 'app', 'package.json'),
JSON.stringify(appPackageJson, null, 2), 'utf-8'
);
const targets = [];
if (options.mac) targets.push(builder.Platform.MAC);
if (options.win) targets.push(builder.Platform.WINDOWS);
if (options.linux) targets.push(builder.Platform.LINUX);
builder.build({
targets: builder.createTargets(targets, null, 'all'),
projectDir: path.join(__dirname, `../dist_${type}`, 'app'),
publish: 'never',
config: {
afterPack(params) {
return Q.try(() => {
shell.cp(
[
path.join(__dirname, '..', 'LICENSE'),
path.join(__dirname, '..', 'README.md'),
path.join(__dirname, '..', 'AUTHORS')
],
params.appOutDir
);
});
}
}