Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function installAppDeps(args: any) {
try {
log.info({version: PACKAGE_VERSION}, "electron-builder")
}
catch (e) {
// error in dev mode without babel
if (!(e instanceof ReferenceError)) {
throw e
}
}
const projectDir = process.cwd()
const packageMetadata = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))
const config = await getConfig(projectDir, null, null, packageMetadata)
const results = await Promise.all([
computeDefaultAppDirectory(projectDir, use(config.directories, it => it!.app)),
getElectronVersion(projectDir, config, packageMetadata),
])
// if two package.json — force full install (user wants to install/update app deps in addition to dev)
await installOrRebuild(config, results[0], {
frameworkInfo: {version: results[1], useCustomDist: true},
platform: args.platform,
arch: args.arch,
productionDeps: createLazyProductionDeps(results[0], null),
}, results[0] !== projectDir)
}
async function build(): Promise<{ packageFile: string }> {
const packager = new Packager({
targets: Platform.LINUX.createTarget("appimage"),
config: await getConfig(
CWD,
path.join(CWD, "./electron-builder.yml"),
null,
),
});
const {artifactPaths: [packageFile]} = await packager.build();
if (!String(packageFile).endsWith(".AppImage")) {
throw new Error(`Invalid artifact: "${packageFile}"`);
}
return {packageFile};
}
async function build(): Promise<{ packageFile: string }> {
const packager = new Packager({
targets: Platform.LINUX.createTarget("snap"),
config: await getConfig(
CWD,
path.join(CWD, "./electron-builder.yml"),
null,
),
});
const {artifactPaths: [packageFile]} = await packager.build();
if (!String(packageFile).endsWith(".snap")) {
throw new Error(`Invalid artifact: "${packageFile}"`);
}
return {packageFile};
}