当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript electron-builder-util.exec函数代码示例

本文整理汇总了TypeScript中electron-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.getTempFile(""), sanitizeFileName(publisher))
  const cer = `${tempPrefix}.cer`
  const pvk = `${tempPrefix}.pvk`

  log(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(`${pfx} created. Please see https://github.com/electron-userland/electron-builder/wiki/Code-Signing how to use it to sign.`)

    const certLocation = "Cert:\\LocalMachine\\TrustedPeople"
    log(`${pfx} will be imported into ${certLocation} 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()
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:28,代码来源:create-self-signed-cert.ts

示例2: 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(),
    ])
  }
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:25,代码来源:macArchiveTest.ts

示例3: 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/)
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:34,代码来源:packTester.ts

示例4: 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
  }
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:32,代码来源:wine.ts

示例5: signAndEditResources

  async signAndEditResources(file: string) {
    const appInfo = this.appInfo

    const args = [
      file,
      "--set-version-string", "CompanyName", appInfo.companyName,
      "--set-version-string", "FileDescription", appInfo.productName,
      "--set-version-string", "ProductName", appInfo.productName,
      "--set-version-string", "InternalName", path.basename(appInfo.productFilename, ".exe"),
      "--set-version-string", "LegalCopyright", appInfo.copyright,
      "--set-version-string", "OriginalFilename", "",
      "--set-file-version", appInfo.buildVersion,
      "--set-product-version", appInfo.versionInWeirdWindowsForm,
    ]

    use(this.platformSpecificBuildOptions.legalTrademarks, it => args.push("--set-version-string", "LegalTrademarks", it!))
    use(await this.getIconPath(), it => args.push("--set-icon", it))

    const rceditExecutable = path.join(await getSignVendorPath(), "rcedit.exe")
    const isWin = process.platform === "win32"
    if (!isWin) {
      args.unshift(rceditExecutable)
    }
    await exec(isWin ? rceditExecutable : "wine", args)

    await this.sign(file)
  }
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:27,代码来源:winPackager.ts

示例6: 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)
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:7,代码来源:codeSign.ts

示例7: main

async function main() {
  const projectDir = process.cwd()
  const config = await loadConfig(projectDir)
  log(`Execute node-gyp rebuild for ${args.platform}:${args.arch}`)
  await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
    env: getGypEnv(await getElectronVersion(config, projectDir), args.platform, args.arch, true),
  })
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:8,代码来源:node-gyp-rebuild.ts

示例8: rebuildAppNativeCode

async function rebuildAppNativeCode(args: any) {
  const projectDir = process.cwd()
  log(`Execute node-gyp rebuild for ${args.platform}:${args.arch}`)
  // this script must be used only for electron
  await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
    env: getGypEnv({version: await getElectronVersion(projectDir), useCustomDist: true}, args.platform, args.arch, true),
  })
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:8,代码来源:cli.ts

示例9: doFlat

  //noinspection JSMethodCanBeStatic
  protected async doFlat(appPath: string, outFile: string, identity: Identity, keychain: string | n): Promise<any> {
    // productbuild doesn't created directory for out file
    await ensureDir(path.dirname(outFile))

    const args = prepareProductBuildArgs(identity, keychain)
    args.push("--component", appPath, "/Applications")
    args.push(outFile)
    return await exec("productbuild", args)
  }
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:10,代码来源:macPackager.ts

示例10: importCerts

async function importCerts(keychainName: string, paths: Array<string>, keyPasswords: Array<string>): Promise<CodeSigningInfo> {
  for (let i = 0; i < paths.length; i++) {
    await exec("security", ["import", paths[i], "-k", keychainName, "-T", "/usr/bin/codesign", "-T", "/usr/bin/productbuild", "-P", keyPasswords[i]])
  }

  return {
    keychainName,
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:9,代码来源:codeSign.ts


注:本文中的electron-builder-util.exec函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。