本文整理汇总了TypeScript中fs-extra-p.readFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript readFile函数的具体用法?TypeScript readFile怎么用?TypeScript readFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readFile函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: async
packed: async(context) => {
expect(safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, archFromString(process.arch)), "app-update.yml"), "utf-8"))).toMatchSnapshot()
const updateInfo = safeLoad(await readFile(path.join(context.outDir, "latest.yml"), "utf-8"))
expect(updateInfo.sha2).not.toEqual("")
expect(updateInfo.releaseDate).not.toEqual("")
delete updateInfo.sha2
delete updateInfo.releaseDate
expect(updateInfo).toMatchSnapshot()
await doTest(context.outDir, false)
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:10,代码来源:nsisTest.ts
示例2: async
packed: async(context) => {
assertThat(safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, Arch.ia32), "app-update.yml"), "utf-8"))).hasProperties({
provider: "generic",
url: "https://develar.s3.amazonaws.com/test",
})
const updateInfo = safeLoad(await readFile(path.join(context.outDir, "latest.yml"), "utf-8"))
assertThat(updateInfo).hasProperties({
version: "1.1.0",
path: "TestApp Setup 1.1.0.exe",
})
assertThat(updateInfo.sha2).isNotEmpty()
await doTest(context.outDir, false)
},
开发者ID:Icenium,项目名称:electron-builder,代码行数:13,代码来源:nsisTest.ts
示例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(),
])
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:25,代码来源:macArchiveTest.ts
示例4: 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())
}
}
开发者ID:GabeIsman,项目名称:electron-builder,代码行数:32,代码来源:packTester.ts
示例5: getLicenseButtons
export async function getLicenseButtons(licenseButtonFiles: Array<LicenseButtonsFile>, langWithRegion: string, id: number, name: string) {
let data = getDefaultButtons(langWithRegion, id, name)
for (const item of licenseButtonFiles) {
if (item.langWithRegion !== langWithRegion) {
continue
}
try {
const fileData = safeLoad(await readFile(item.file, "utf-8")) as any
const buttonsStr = labelToHex(fileData.lang, item.lang, item.langWithRegion) +
labelToHex(fileData.agree, item.lang, item.langWithRegion) +
labelToHex(fileData.disagree, item.lang, item.langWithRegion) +
labelToHex(fileData.print, item.lang, item.langWithRegion) +
labelToHex(fileData.save, item.lang, item.langWithRegion) +
labelToHex(fileData.description, item.lang, item.langWithRegion)
data = `data 'STR#' (${id}, "${name}") {\n`
data += serializeString("0006" + buttonsStr)
data += `\n};`
if (log.isDebugEnabled) {
log.debug({lang: item.langName, data}, `overwriting license buttons`)
}
return data
}
catch (e) {
log.debug({error: e}, "cannot overwrite license buttons")
return data
}
}
return data
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:34,代码来源:licenseButtons.ts
示例6: 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(),
])
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:29,代码来源:macArchiveTest.ts
示例7: 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())
}
}
开发者ID:SimplyAhmazing,项目名称:electron-builder,代码行数:32,代码来源:packTester.ts
示例8: getGitUrlFromGitConfig
async function getGitUrlFromGitConfig(): Promise<string | null> {
let data: string | null = null
try {
data = await readFile(path.join(".git", "config"), "utf8")
}
catch (e) {
if (e.code === "ENOENT") {
return null
}
throw e
}
const conf = data.split(/\r?\n/)
const i = conf.indexOf('[remote "origin"]')
if (i !== -1) {
let u = conf[i + 1]
if (!u.match(/^\s*url =/)) {
u = conf[i + 2]
}
if (u.match(/^\s*url =/)) {
return u.replace(/^\s*url = /, "")
}
}
return null
}
开发者ID:ArchMa9e,项目名称:electron-builder,代码行数:27,代码来源:repositoryInfo.ts
示例9: exec
packed: async context => {
const pkgPath = path.join(context.outDir, "Test App ßW-1.1.0.pkg")
const unpackedDir = path.join(context.outDir, "pkg-unpacked")
await exec("pkgutil", ["--expand", pkgPath, unpackedDir])
const packageInfoFile = path.join(unpackedDir, "org.electron-builder.testApp.pkg", "PackageInfo")
const info = parseXml(await readFile(packageInfoFile, "utf8"))
const relocateElement = info.elementOrNull("relocate")
if (relocateElement) {
expect(relocateElement.elements).toBeNull()
}
const upgradeBundleElement = info.elementOrNull("upgrade-bundle")
if (upgradeBundleElement) {
expect(upgradeBundleElement.elements).toBeNull()
}
const updateBundleElement = info.elementOrNull("update-bundle")
if (updateBundleElement) {
expect(updateBundleElement.elements).toHaveLength(1)
}
const strictIdentifierElement = info.elementOrNull("strict-identifier")
if (strictIdentifierElement) {
expect(strictIdentifierElement.elements).toBeNull()
}
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:28,代码来源:macArchiveTest.ts
示例10: assertThat
packed: async context => {
const base = path.join(context.outDir, `${platform.buildConfigurationKey}-unpacked`)
let resourcesDir = path.join(base, "resources")
if (platform === Platform.MAC) {
resourcesDir = path.join(base, "TestApp.app", "Contents", "Resources")
}
const appDir = path.join(resourcesDir, "app")
await BluebirdPromise.all([
assertThat(path.join(resourcesDir, "foo")).isDirectory(),
assertThat(path.join(appDir, "foo")).doesNotExist(),
assertThat(path.join(resourcesDir, "foo", "nameWithoutDot")).isFile(),
assertThat(path.join(appDir, "foo", "nameWithoutDot")).doesNotExist(),
assertThat(path.join(resourcesDir, "bar", "hello.txt")).isFile(),
assertThat(path.join(resourcesDir, "bar", `${process.arch}.txt`)).isFile(),
assertThat(path.join(appDir, "bar", `${process.arch}.txt`)).doesNotExist(),
assertThat(path.join(resourcesDir, osName, `${process.arch}.txt`)).isFile(),
assertThat(path.join(resourcesDir, "platformSpecificR")).isFile(),
assertThat(path.join(resourcesDir, "ignoreMe.txt")).doesNotExist(),
allCan(path.join(resourcesDir, "executable"), true),
allCan(path.join(resourcesDir, "executableOnlyOwner"), true),
allCan(path.join(resourcesDir, "bar", "hello.txt"), false),
])
expect(await readFile(path.join(resourcesDir, "bar", "hello.txt"), "utf-8")).toEqual("data")
},
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:31,代码来源:filesTest.ts
注:本文中的fs-extra-p.readFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论