本文整理匯總了TypeScript中out/util/util.exec函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript exec函數的具體用法?TypeScript exec怎麽用?TypeScript exec使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了exec函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: checkOsXResult
async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>) {
const appInfo = packager.appInfo
const packedAppDir = path.join(path.dirname(artifacts[0].file), `${appInfo.productFilename}.app`)
const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8"))
assertThat2(info).has.properties({
CFBundleDisplayName: appInfo.productName,
CFBundleIdentifier: "org.electron-builder.testApp",
LSApplicationCategoryType: "your.app.category.type",
CFBundleVersion: `${appInfo.version}.${(process.env.TRAVIS_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM)}`
})
if (packagerOptions.cscLink != null) {
const result = await exec("codesign", ["--verify", packedAppDir])
assertThat2(result).not.match(/is not signed at all/)
}
const actualFiles = artifacts.map(it => path.basename(it.file)).sort()
if (checkOptions != null && checkOptions.expectedContents != null) {
assertThat(actualFiles).isEqualTo(checkOptions.expectedContents)
}
else {
assertThat(actualFiles).isEqualTo([
`${appInfo.productFilename}-${appInfo.version}-mac.zip`,
`${appInfo.productFilename}-${appInfo.version}.dmg`,
].sort())
assertThat(artifacts.map(it => it.artifactName).sort()).isEqualTo([
`TestApp-${appInfo.version}-mac.zip`,
`TestApp-${appInfo.version}.dmg`,
].sort())
}
}
示例2: 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
}
示例3: getContents
async function getContents(path: string) {
const result = await exec("dpkg", ["--contents", path])
return pathSorter(result
.split("\n")
.map(it => it.length === 0 ? null : it.substring(it.indexOf(".") + 1))
.filter(it => it != null && !(it.includes(`/locales/`) || it.includes(`/libgcrypt`)))
)
}
示例4: checkLinuxResult
async function checkLinuxResult(projectDir: string, packager: Packager, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>, arch: Arch, nameToTarget: Map<String, Target>) {
const appInfo = packager.appInfo
function getExpected(): Array<string> {
const result: Array<string> = []
for (let target of nameToTarget.keys()) {
if (target === "appimage") {
result.push(`${appInfo.name}-${appInfo.version}-${arch === Arch.x64 ? "x86_64" : Arch[arch]}.AppImage`)
}
else {
result.push(`TestApp-${appInfo.version}.${target}`)
}
}
return result
}
assertThat(getFileNames(artifacts)).containsAll(getExpected())
if (!nameToTarget.has("deb")) {
return
}
const productFilename = appInfo.productFilename
const expectedContents = pathSorter(expectedLinuxContents.map(it => {
if (it === "/opt/TestApp/TestApp") {
return "/opt/" + productFilename + "/" + productFilename
}
else if (it === "/usr/share/applications/TestApp.desktop") {
return `/usr/share/applications/${productFilename}.desktop`
}
else {
return it.replace(new RegExp("/opt/TestApp/", "g"), `/opt/${productFilename}/`)
}
}))
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName), null, 2))
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2))
const packageFile = `${projectDir}/${outDirName}/TestApp-${appInfo.version}.deb`
assertThat(await getContents(packageFile)).isEqualTo(expectedContents)
if (arch === Arch.ia32) {
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${appInfo.version}-i386.deb`)).isEqualTo(expectedContents)
}
assertThat2(parseDebControl(await exec("dpkg", ["--info", packageFile]))).has.properties({
License: "MIT",
Homepage: "http://foo.example.com",
Maintainer: "Foo Bar <foo@example.com>",
Vendor: "Foo Bar <foo@example.com>",
Package: "testapp",
Description: " \n Test Application (test quite â #378)",
Depends: checkOptions == null || checkOptions.expectedDepends == null ? "libappindicator1, libnotify-bin" : checkOptions.expectedDepends,
})
}
示例5: checkLinuxResult
async function checkLinuxResult(projectDir: string, packager: Packager, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>, arch: Arch) {
const customBuildOptions = packager.devMetadata.build.linux
const targets = customBuildOptions == null || customBuildOptions.target == null ? ["default"] : customBuildOptions.target
function getExpected(): Array<string> {
const result: Array<string> = []
for (let target of targets) {
result.push(`TestApp-${packager.appInfo.version}.${target === "default" ? "deb" : target}`)
}
return result
}
assertThat(getFileNames(artifacts)).containsAll(getExpected())
if (!targets.includes("deb") || !targets.includes("default")) {
return
}
const productName = packager.appInfo.productName
const expectedContents = expectedLinuxContents.map(it => {
if (it === "/opt/TestApp/TestApp") {
return "/opt/" + productName + "/" + productName
}
else if (it === "/usr/share/applications/TestApp.desktop") {
return `/usr/share/applications/${productName}.desktop`
}
else {
return it.replace(new RegExp("/opt/TestApp/", "g"), `/opt/${productName}/`)
}
})
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName), null, 2))
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2))
const packageFile = `${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}-amd64.deb`
assertThat(await getContents(packageFile, productName)).isEqualTo(expectedContents)
if (arch === Arch.ia32) {
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}-i386.deb`, productName)).isEqualTo(expectedContents)
}
assertThat2(parseDebControl(await exec("dpkg", ["--info", packageFile]))).has.properties({
License: "MIT",
Homepage: "http://foo.example.com",
Maintainer: "Foo Bar <foo@example.com>",
Vendor: "Foo Bar <foo@example.com>",
Package: "testapp",
Description: " \n Test Application (test quite â #378)",
Depends: checkOptions == null || checkOptions.expectedDepends == null ? "libappindicator1, libnotify-bin" : checkOptions.expectedDepends,
})
}
示例6: exec
exec(...args: Array<string>) {
return exec("wine", args, {env: this.env})
}