本文整理汇总了TypeScript中builder-util.exec函数的典型用法代码示例。如果您正苦于以下问题:TypeScript exec函数的具体用法?TypeScript exec怎么用?TypeScript exec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exec函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createSelfSignedCert
export async function createSelfSignedCert(publisher: string) {
const tmpDir = new TmpDir()
const targetDir = process.cwd()
const tempPrefix = path.join(await tmpDir.getTempDir({prefix: "self-signed-cert-creator"}), sanitizeFileName(publisher))
const cer = `${tempPrefix}.cer`
const pvk = `${tempPrefix}.pvk`
log.info(chalk.bold('When asked to enter a password ("Create Private Key Password"), please select "None".'))
try {
await ensureDir(path.dirname(tempPrefix))
const vendorPath = path.join(await getSignVendorPath(), "windows-10", process.arch)
await exec(path.join(vendorPath, "makecert.exe"),
["-r", "-h", "0", "-n", `CN=${quoteString(publisher)}`, "-eku", "1.3.6.1.5.5.7.3.3", "-pe", "-sv", pvk, cer])
const pfx = path.join(targetDir, `${sanitizeFileName(publisher)}.pfx`)
await unlinkIfExists(pfx)
await exec(path.join(vendorPath, "pvk2pfx.exe"), ["-pvk", pvk, "-spc", cer, "-pfx", pfx])
log.info({file: pfx}, `created. Please see https://electron.build/code-signing how to use it to sign.`)
const certLocation = "Cert:\\LocalMachine\\TrustedPeople"
log.info({file: pfx, certLocation}, `importing. Operation will be succeed only if runned from root. Otherwise import file manually.`)
await spawn("powershell.exe", ["Import-PfxCertificate", "-FilePath", `"${pfx}"`, "-CertStoreLocation", ""])
}
finally {
await tmpDir.cleanup()
}
}
示例2: pathSorter
packed: async context => {
const pkgPath = path.join(context.outDir, "Test App ĂW-1.1.0.pkg")
console.log("CALL")
const fileList = pathSorter(parseFileList(await exec("pkgutil", ["--payload-files", pkgPath]), false))
expect(fileList).toMatchSnapshot()
const unpackedDir = path.join(context.outDir, "pkg-unpacked")
await exec("pkgutil", ["--expand", pkgPath, unpackedDir])
const info = parseXml(await readFile(path.join(unpackedDir, "Distribution"), "utf8"))
for (const element of info.getElements("pkg-ref")) {
element.removeAttribute("installKBytes")
const bundleVersion = element.elementOrNull("bundle-version")
if (bundleVersion != null) {
bundleVersion.element("bundle").removeAttribute("CFBundleVersion")
}
}
// delete info.product.version
info.element("product").removeAttribute("version")
expect(info).toMatchSnapshot()
const scriptDir = path.join(unpackedDir, "org.electron-builder.testApp.pkg", "Scripts")
await Promise.all([
assertThat(path.join(scriptDir, "postinstall")).isFile(),
assertThat(path.join(scriptDir, "preinstall")).isFile(),
])
}
示例3: pathSorter
packed: async context => {
const pkgPath = path.join(context.outDir, "Test App ĂW-1.1.0.pkg")
const fileList = pathSorter(parseFileList(await exec("pkgutil", ["--payload-files", pkgPath]), false))
expect(fileList).toMatchSnapshot()
const unpackedDir = path.join(context.outDir, "pkg-unpacked")
await exec("pkgutil", ["--expand", pkgPath, unpackedDir])
const m: any = BluebirdPromise.promisify(parseString)
const info = await m(await readFile(path.join(unpackedDir, "Distribution"), "utf8"), {
explicitRoot: false,
explicitArray: false,
mergeAttrs: true,
})
delete info["pkg-ref"][0]["bundle-version"].bundle.CFBundleVersion
delete info["pkg-ref"][1].installKBytes
delete info.product.version
expect(info).toMatchSnapshot()
const scriptDir = path.join(unpackedDir, "org.electron-builder.testApp.pkg", "Scripts")
await BluebirdPromise.all([
assertThat(path.join(scriptDir, "postinstall")).isFile(),
assertThat(path.join(scriptDir, "preinstall")).isFile(),
])
}
示例4: extractPng
async function extractPng(index: number, suffix: string) {
await exec("tiffutil", ["-extract", index.toString(), path.join(getDmgTemplatePath(), "background.tiff")], {
cwd: projectDir
})
await exec("sips", ["-s", "format", "png", "out.tiff", "--out", `background${suffix}.png`], {
cwd: projectDir
})
}
示例5: createEmbeddedArchiveFile
private async createEmbeddedArchiveFile(nupkgPath: string, dirToArchive: string) {
const embeddedArchiveFile = await this.packager.getTempFile("setup.zip")
await exec(path7za, compute7zCompressArgs("zip", {
isRegularFile: true,
compression: this.packager.compression,
}).concat(embeddedArchiveFile, "."), {
cwd: dirToArchive,
})
await exec(path7za, compute7zCompressArgs("zip", {
isRegularFile: true,
compression: "store" /* nupkg is already compressed */,
}).concat(embeddedArchiveFile, nupkgPath))
return embeddedArchiveFile
}
示例6: importCerts
async function importCerts(keychainName: string, paths: Array<string>, keyPasswords: Array<string>): Promise<CodeSigningInfo> {
for (let i = 0; i < paths.length; i++) {
const password = keyPasswords[i]
await exec("security", ["import", paths[i], "-k", keychainName, "-T", "/usr/bin/codesign", "-T", "/usr/bin/productbuild", "-P", password])
// https://stackoverflow.com/questions/39868578/security-codesign-in-sierra-keychain-ignores-access-control-settings-and-ui-p
// https://github.com/electron-userland/electron-packager/issues/701#issuecomment-322315996
if (await isMacOsSierra()) {
await exec("security", ["set-key-partition-list", "-S", "apple-tool:,apple:", "-s", "-k", password, keychainName])
}
}
return {
keychainName,
}
}
示例7: archive
export async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {
const args = compute7zCompressArgs(format, options)
// remove file before - 7z doesn't overwrite file, but update
await unlinkIfExists(outFile)
args.push(outFile, options.withoutDir ? "." : path.basename(dirToArchive))
if (options.excluded != null) {
for (const mask of options.excluded) {
args.push(`-xr!${mask}`)
}
}
try {
await exec(path7za, args, {
cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive),
}, debug7z.enabled)
}
catch (e) {
if (e.code === "ENOENT" && !(await exists(dirToArchive))) {
throw new Error(`Cannot create archive: "${dirToArchive}" doesn't exist`)
}
else {
throw e
}
}
return outFile
}
示例8: checkMacResult
async function checkMacResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, packedAppDir: string) {
const appInfo = packager.appInfo
const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8"))
expect(info).toMatchObject({
CFBundleDisplayName: appInfo.productName,
CFBundleIdentifier: "org.electron-builder.testApp",
LSApplicationCategoryType: "your.app.category.type",
CFBundleVersion: info.CFBundleVersion === "50" ? "50" : `${appInfo.version}.${(process.env.TRAVIS_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM)}`
})
// checked manually, remove to avoid mismatch on CI server (where TRAVIS_BUILD_NUMBER is defined and different on each test run)
delete info.CFBundleVersion
delete info.NSHumanReadableCopyright
const checksumData = info.AsarIntegrity
if (checksumData != null) {
const data = JSON.parse(checksumData)
const checksums = data.checksums
for (const name of Object.keys(checksums)) {
checksums[name] = "hash"
}
info.AsarIntegrity = JSON.stringify(data)
}
if (checkOptions.checkMacApp != null) {
await checkOptions.checkMacApp(packedAppDir, info)
}
if (packagerOptions.cscLink != null) {
const result = await exec("codesign", ["--verify", packedAppDir])
expect(result).not.toMatch(/is not signed at all/)
}
}
示例9: prepareWine
async prepareWine(wineDir: string) {
await emptyDir(wineDir)
//noinspection SpellCheckingInspection
const env = Object.assign({}, process.env, {
WINEDLLOVERRIDES: "winemenubuilder.exe=d",
WINEPREFIX: wineDir
})
await exec("wineboot", ["--init"], {env: env})
// regedit often doesn't modify correctly
let systemReg = await readFile(path.join(wineDir, "system.reg"), "utf8")
systemReg = systemReg.replace('"CSDVersion"="Service Pack 3"', '"CSDVersion"=" "')
systemReg = systemReg.replace('"CurrentBuildNumber"="2600"', '"CurrentBuildNumber"="10240"')
systemReg = systemReg.replace('"CurrentVersion"="5.1"', '"CurrentVersion"="10.0"')
systemReg = systemReg.replace('"ProductName"="Microsoft Windows XP"', '"ProductName"="Microsoft Windows 10"')
systemReg = systemReg.replace('"CSDVersion"=dword:00000300', '"CSDVersion"=dword:00000000')
await writeFile(path.join(wineDir, "system.reg"), systemReg)
// remove links to host OS
const desktopDir = path.join(this.userDir, "Desktop")
await BluebirdPromise.all([
unlinkIfExists(desktopDir),
unlinkIfExists(path.join(this.userDir, "My Documents")),
unlinkIfExists(path.join(this.userDir, "My Music")),
unlinkIfExists(path.join(this.userDir, "My Pictures")),
unlinkIfExists(path.join(this.userDir, "My Videos")),
])
await ensureDir(desktopDir)
return env
}
示例10: sign
export function sign(path: string, name: string, keychain: string): Promise<any> {
const args = ["--deep", "--force", "--sign", name, path]
if (keychain != null) {
args.push("--keychain", keychain)
}
return exec("codesign", args)
}