Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Copy all files to a tmp dir to avoid including scrap files in the ASAR
for (const file of files) {
const newLocation = path.resolve(tmpPath, path.relative(base[0], file))
fs.mkdirsSync(path.dirname(newLocation))
fs.writeFileSync(newLocation, fs.readFileSync(file))
}
} catch (err) {
console.error('Unexpected error while generating ASAR', err)
fs.remove(tmpPath)
.then(() => process.exit(1))
.catch(() => process.exit(1))
return
}
// Create the ASAR archive
asar.createPackageWithOptions(tmpPath, out[0], {})
.catch(err => {
const exit = () => {
console.error('Unexpected error while generating ASAR', err)
process.exit(1)
}
fs.remove(tmpPath).then(exit).catch(exit)
}).then(() => fs.remove(tmpPath))
var libPath = path.join(__dirname, '..', '..', 'lib')
rimraf.sync(path.join(outputPath, 'lib'))
glob.sync('**/*.js', {cwd: libPath}).forEach(function (relativePath) {
var rawPath = path.join(libPath, relativePath)
var raw = fs.readFileSync(rawPath, 'utf8')
var generatedPath = path.join(outputPath, 'lib', relativePath)
var generated = instrumenter.instrumentSync(raw, rawPath)
mkdirp.sync(path.dirname(generatedPath))
fs.writeFileSync(generatedPath, generated)
})
var asarPath = path.join(outputPath, 'electron.asar')
asar.createPackageWithOptions(path.join(outputPath, 'lib'), asarPath, {}, function (error) {
if (error) {
console.error(error.stack || error)
process.exit(1)
}
})
asarApp () {
if (!this.asarOptions) {
return Promise.resolve()
}
debug(`Running asar with the options ${JSON.stringify(this.asarOptions)}`)
return asar.createPackageWithOptions(this.originalResourcesAppDir, this.appAsarPath, this.asarOptions)
.then(() => fs.remove(this.originalResourcesAppDir))
}
var packageBuiltApp = function () {
var deferred = Q.defer();
asar.createPackageWithOptions(projectDir.path('app'), readyAppDir.path('resources/app.asar'), {
dot: true
}, function () {
deferred.resolve();
});
return deferred.promise;
};
let packageBuiltApp = function () {
let deferred = Q.defer()
asar.createPackageWithOptions(projectDir.path('build'), readyAppDir.path('resources/app.asar'), {
dot: true
}, function () {
deferred.resolve()
})
return deferred.promise
}
let packageBuiltApp = function () {
let deferred = Q.defer()
asar.createPackageWithOptions(projectDir.path('build'), readyAppDir.path('resources/app.asar'), {
dot: true
}, function () {
deferred.resolve()
})
return deferred.promise
}
var packageBuiltApp = function () {
var deferred = Q.defer();
asar.createPackageWithOptions(projectDir.path('app'), readyAppDir.path('resources/app.asar'), {
dot: true
}, function () {
deferred.resolve();
});
return deferred.promise;
};
function asarApp (appPath, asarOptions, cb) {
var dest = path.join(appPath, '..', 'app.asar')
debug(`Running asar with the options ${JSON.stringify(asarOptions)}`)
asar.createPackageWithOptions(appPath, dest, asarOptions, function (err) {
if (err) return cb(err)
fs.remove(appPath, function (err) {
if (err) return cb(err)
cb(null, dest)
})
})
}
async function asarApp (root: string) {
await createPackageWithOptions(root, path.join(root, '../app.asar'), { unpack: process.platform === 'linux' ? `{*.node,**/${path.basename(config.outputPath)}/${config.iconOutDir}/*.png}` : '*.node' })
await fs.remove(root)
}