Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOptions, artifacts: Array, nameToTarget: Map) {
const appInfo = packager.appInfo
let squirrel = false
for (const target of nameToTarget.keys()) {
if (target === "squirrel") {
squirrel = true
break
}
}
if (!squirrel) {
return
}
const packageFile = artifacts.find(it => it.file!!.endsWith("-full.nupkg"))!.file!!
const unZipper = new DecompressZip(packageFile!!)
const fileDescriptors = await unZipper.getFiles()
// we test app-update.yml separately, don't want to complicate general assert (yes, it is not good that we write app-update.yml for squirrel.windows if we build nsis and squirrel.windows in parallel, but as squirrel.windows is deprecated, it is ok)
const files = pathSorter(fileDescriptors.map(it => toSystemIndependentPath(it.path))
.filter(it => (!it.startsWith("lib/net45/locales/") || it === "lib/net45/locales/en-US.pak") && !it.endsWith(".psmdcp") && !it.endsWith("app-update.yml") && !it.includes("/inspector/")))
expect(files).toMatchSnapshot()
if (checkOptions == null) {
await unZipper.extractFile(fileDescriptors.filter(it => it.path === "TestApp.nuspec")[0], {
path: path.dirname(packageFile),
})
const expectedSpec = (await fs.readFile(path.join(path.dirname(packageFile), "TestApp.nuspec"), "utf8")).replace(/\r\n/g, "\n")
// console.log(expectedSpec)
expect(expectedSpec).toEqual(`
return new Promise((resolve, reject) => {
const target = path.join(path.resolve(this.basedir), this.name);
this.emit('notify', `Unpacking ${zip} to ${target}`);
const unzipper = new DecompressZip(zip);
unzipper.on('error', (err) => {
this.emit('error', err);
reject(err);
});
unzipper.on('extract', () => {
fs.chmod(target, 0o755, (moderr) => {
if (moderr) {
reject(moderr);
}
resolve(true);
});
});
unzipper.extract({
path: this.basedir,
filter: file =>
// https://github.com/bower/decompress-zip/blob/master/lib/file-details.js#L10
return new Promise((resolve, reject) => {
const unzipper = new DecompressZip(jscAARPath)
const unzipOutDir = createTmpDir()
const containerJniLibsPath = path.join(
config.outDir,
'lib/src/main/jniLibs'
)
const unzippedJniPath = path.join(unzipOutDir, 'jni')
unzipper.on('error', err => reject(err))
unzipper.on('extract', () => {
shell.cp('-Rf', unzippedJniPath, containerJniLibsPath)
resolve()
})
unzipper.extract({ path: unzipOutDir })
})
} finally {
return new Promise((resolve, reject) => {
const unzipper = new DecompressZip(zippath);
unzipper.on("error", err => {
return reject(`Failed to decompress zip file: ${err}`);
});
unzipper.on("extract", () => {
resolve();
});
unzipper.extract({
path: extractpath,
strip: 1
});
});
}
return new Promise((resolve, reject) => {
const unzipper = new DecompressZip(hermesAarPath)
const unzipOutDir = createTmpDir()
const containerJniLibsPath = path.join(
config.outDir,
'lib/src/main/jniLibs'
)
const unzippedJniPath = path.join(unzipOutDir, 'jni')
unzipper.on('error', err => reject(err))
unzipper.on('extract', () => {
shell.cp('-Rf', unzippedJniPath, containerJniLibsPath)
resolve()
})
unzipper.extract({ path: unzipOutDir })
})
} finally {