本文整理汇总了TypeScript中out/util.exec函数的典型用法代码示例。如果您正苦于以下问题:TypeScript exec函数的具体用法?TypeScript exec怎么用?TypeScript exec使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exec函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: checkOsXResult
async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>) {
const productName = getProductName(packager.metadata, packager.devMetadata)
const packedAppDir = path.join(path.dirname(artifacts[0].file), (productName || packager.metadata.name) + ".app")
const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8"))
assertThat(info).has.properties({
CFBundleDisplayName: productName,
CFBundleIdentifier: "your.id",
LSApplicationCategoryType: "your.app.category.type",
CFBundleVersion: "1.1.0" + "." + (process.env.TRAVIS_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM)
})
if (packagerOptions.csaLink != null) {
const result = await exec("codesign", ["--verify", packedAppDir])
assertThat(result[0].toString()).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).deepEqual(checkOptions.expectedContents)
}
else {
assertThat(actualFiles).deepEqual([
`${productName}-1.1.0-mac.zip`,
`${productName}-1.1.0.dmg`,
].sort())
assertThat(artifacts.map(it => it.artifactName).sort()).deepEqual([
"TestApp-1.1.0-mac.zip",
"TestApp-1.1.0.dmg",
].sort())
}
}
示例2: checkLinuxResult
async function checkLinuxResult(projectDir: string, packager: Packager, packagerOptions: PackagerOptions) {
const productName = getProductName(packager.metadata, packager.devMetadata)
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-1.1.0-amd64.deb`
assertThat(await getContents(packageFile, productName)).deepEqual(expectedContents)
if (packagerOptions.arch === "all" || packagerOptions.arch === "ia32") {
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-1.1.0-i386.deb`, productName)).deepEqual(expectedContents)
}
assertThat(parseDebControl((await exec("dpkg", ["--info", packageFile])).toString())).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",
})
}
示例3: checkOsXResult
async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>) {
const appInfo = packager.appInfo
const productName = appInfo.productName
const packedAppDir = path.join(path.dirname(artifacts[0].file), (productName || packager.metadata.name) + ".app")
const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8"))
assertThat2(info).has.properties({
CFBundleDisplayName: 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([
`${productName}-${appInfo.version}-mac.zip`,
`${productName}-${appInfo.version}.dmg`,
].sort())
assertThat(artifacts.map(it => it.artifactName).sort()).isEqualTo([
`TestApp-${appInfo.version}-mac.zip`,
`TestApp-${appInfo.version}.dmg`,
].sort())
}
}
示例4: getContents
async function getContents(path: string, productName: string) {
const result = await exec("dpkg", ["--contents", path])
return pathSorter(result[0].toString()
.split("\n")
.map(it => it.length === 0 ? null : it.substring(it.indexOf(".") + 1))
.filter(it => it != null && !(it.startsWith(`/opt/${productName}/locales/`) || it.startsWith(`/opt/${productName}/libgcrypt`)))
)
}
示例5: checkLinuxResult
async function checkLinuxResult(projectDir: string, packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>) {
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-1.1.0.${target === "default" ? "deb" : target}`)
}
return result
}
assertThat(getFileNames(artifacts)).deepEqual((checkOptions == null || checkOptions.expectedArtifacts == null ? getExpected() : checkOptions.expectedArtifacts.slice()).sort())
if (!targets.includes("deb") || !targets.includes("default")) {
return
}
const productName = getProductName(packager.metadata, packager.devMetadata)
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-1.1.0-amd64.deb`
assertThat(await getContents(packageFile, productName)).deepEqual(expectedContents)
if (packagerOptions.arch === "all" || packagerOptions.arch === "ia32") {
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-1.1.0-i386.deb`, productName)).deepEqual(expectedContents)
}
assertThat(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: checkOsXResult
async function checkOsXResult(packager: Packager, artifacts: Array<string>) {
const productName = getProductName(packager.metadata)
const packedAppDir = path.join(path.dirname(artifacts[0]), (productName || packager.metadata.name) + ".app")
const info = parsePlist(await readText(path.join(packedAppDir, "Contents", "Info.plist")))
assertThat(info).has.properties({
CFBundleDisplayName: productName,
CFBundleIdentifier: "your.id",
LSApplicationCategoryType: "your.app.category.type",
CFBundleVersion: "1.0.0" + "." + (process.env.TRAVIS_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM)
})
const result = await exec("codesign", ["--verify", packedAppDir])
assertThat(result[0].toString()).not.match(/is not signed at all/)
assertThat(artifacts.map(it => path.basename((it))).sort()).deepEqual([
"TestApp-1.0.0-mac.zip",
"TestApp-1.0.0.dmg"
].sort())
}
示例7: checkLinuxResult
async function checkLinuxResult(projectDir: string, packager: Packager, packagerOptions: PackagerOptions) {
const productName = getProductName(packager.metadata, packager.devMetadata)
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 + "/dist/TestApp-1.0.0-amd64.deb"
assertThat(await getContents(packageFile, productName)).deepEqual(expectedContents)
if (packagerOptions.arch === "all" || packagerOptions.arch === "ia32") {
assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName)).deepEqual(expectedContents)
}
const regexp = /^ *(\w+): *(.+)$/gm
const info = (await exec("dpkg", ["--info", packageFile])).toString()
let match: Array<string>
const metadata: any = {}
while ((match = regexp.exec(info)) !== null) {
metadata[match[1]] = match[2]
}
assertThat(metadata).has.properties({
License: "MIT",
Homepage: "http://foo.example.com",
Maintainer: "Foo Bar <foo@example.com>",
Package: "testapp",
Description: "Test Application",
})
}