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


TypeScript promisifed-fs.readText函数代码示例

本文整理汇总了TypeScript中out/promisifed-fs.readText函数的典型用法代码示例。如果您正苦于以下问题:TypeScript readText函数的具体用法?TypeScript readText怎么用?TypeScript readText使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了readText函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: checkWindowsResult

async function checkWindowsResult(packager: Packager, packagerOptions: PackagerOptions, artifacts: Array<ArtifactCreated>) {
  const productName = getProductName(packager.metadata, packager.devMetadata)

  function getWinExpected(archSuffix: string) {
    return [
      `RELEASES${archSuffix}`,
      `${productName}Setup-1.0.0${archSuffix}.exe`,
      `TestApp-1.0.0${archSuffix}-full.nupkg`,
    ]
  }

  const archSuffix = packagerOptions != null && packagerOptions.arch === "x64" ? "" : "-ia32"
  const expected = archSuffix == "" ? getWinExpected(archSuffix) : getWinExpected(archSuffix).concat(getWinExpected(""))

  const filenames = artifacts.map(it => path.basename(it.file))
  assertThat(filenames.slice().sort()).deepEqual(expected.slice().sort())

  let i = filenames.indexOf("RELEASES-ia32")
  if (i !== -1) {
    assertThat((await readText(artifacts[i].file)).indexOf("ia32")).not.equal(-1)
  }

  if (archSuffix == "") {
    const expectedArtifactNames = expected.slice()
    expectedArtifactNames[1] = `TestAppSetup-1.0.0${archSuffix}.exe`
    assertThat(artifacts.map(it => it.artifactName).filter(it => it != null)).deepEqual([`TestAppSetup-1.0.0${archSuffix}.exe`])
  }
}
开发者ID:bundyo,项目名称:electron-builder,代码行数:28,代码来源:packTester.ts

示例2: checkWindowsResult

async function checkWindowsResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>) {
  const productName = getProductName(packager.metadata, packager.devMetadata)

  function getWinExpected(archSuffix: string) {
    return [
      `RELEASES${archSuffix}`,
      `${productName}Setup-1.0.0${archSuffix}.exe`,
      `TestApp-1.0.0${archSuffix}-full.nupkg`,
    ]
  }

  const archSuffix = (packagerOptions.arch || process.arch) === "x64" ? "" : "-ia32"
  const expected = archSuffix == "" ? getWinExpected(archSuffix) : getWinExpected(archSuffix).concat(getWinExpected(""))

  const filenames = artifacts.map(it => path.basename(it.file))
  assertThat(filenames.slice().sort()).deepEqual(expected.slice().sort())

  let i = filenames.indexOf("RELEASES-ia32")
  if (i !== -1) {
    assertThat((await readText(artifacts[i].file)).indexOf("ia32")).not.equal(-1)
  }

  if (archSuffix == "") {
    const expectedArtifactNames = expected.slice()
    expectedArtifactNames[1] = `TestAppSetup-1.0.0${archSuffix}.exe`
    assertThat(artifacts.map(it => it.artifactName).filter(it => it != null)).deepEqual([`TestAppSetup-1.0.0${archSuffix}.exe`])
  }

  const files = pathSorter((await new BluebirdPromise<Array<string>>((resolve, reject) => {
    const unZipper = new DecompressZip(path.join(path.dirname(artifacts[0].file), `TestApp-1.0.0${archSuffix}-full.nupkg`))
    unZipper.on("list", resolve)
    unZipper.on('error', reject)
    unZipper.list()
  })).map(it => it.replace(/\\/g, "/")).filter(it => (!it.startsWith("lib/net45/locales/") || it === "lib/net45/locales/en-US.pak") && !it.endsWith(".psmdcp")))

  // console.log(JSON.stringify(files, null, 2))
  const expectedContents = checkOptions == null || checkOptions.expectedContents == null ? expectedWinContents : checkOptions.expectedContents
  assertThat(files).deepEqual(expectedContents.map(it => {
    if (it === "lib/net45/TestApp.exe") {
      return `lib/net45/${productName.replace(/ /g, "%20")}.exe`
    }
    else {
      return it
    }
  }))
}
开发者ID:dennyferra,项目名称:electron-builder,代码行数:46,代码来源:packTester.ts

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

示例4: checkWindowsResult

async function checkWindowsResult(packagerOptions: PackagerOptions, artifacts: Array<string>) {
  const expected32 = [
    "RELEASES-ia32",
    "TestApp-1.0.0-full.nupkg",
    "TestAppSetup-1.0.0.exe"
  ]
  const expected64 = [
    "RELEASES",
    "TestAppSetup-1.0.0-x64.exe",
    "TestApp-1.0.0-x64-full.nupkg"
  ]
  const expected = packagerOptions != null && packagerOptions.arch === "x64" ? expected64 : expected32.concat(expected64)
  const filenames = artifacts.map(it => path.basename((it)))
  assertThat(filenames.slice().sort()).deepEqual(expected.sort())

  let i = filenames.indexOf("RELEASES")
  if (i !== -1) {
    assertThat((await readText(artifacts[i])).indexOf("x64")).not.equal(-1)
  }
}
开发者ID:TakT,项目名称:electron-builder,代码行数:20,代码来源:packTester.ts

示例5: checkWindowsResult

async function checkWindowsResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>) {
  const productName = getProductName(packager.metadata, packager.devMetadata)

  function getWinExpected(archSuffix: string) {
    return [
      `RELEASES${archSuffix}`,
      `${productName}Setup-1.1.0${archSuffix}.exe`,
      `TestApp-1.1.0${archSuffix}-full.nupkg`,
    ]
  }

  const archSuffix = (packagerOptions.arch || process.arch) === "x64" ? "" : "-ia32"
  const expected = archSuffix == "" ? getWinExpected(archSuffix) : getWinExpected(archSuffix).concat(getWinExpected(""))

  const filenames = artifacts.map(it => path.basename(it.file))
  assertThat(filenames.slice().sort()).deepEqual(expected.slice().sort())

  let i = filenames.indexOf("RELEASES-ia32")
  if (i !== -1) {
    assertThat((await readText(artifacts[i].file)).indexOf("ia32")).not.equal(-1)
  }

  if (archSuffix == "") {
    const expectedArtifactNames = expected.slice()
    expectedArtifactNames[1] = `TestAppSetup-1.1.0${archSuffix}.exe`
    assertThat(artifacts.map(it => it.artifactName).filter(it => it != null)).deepEqual([`TestAppSetup-1.1.0${archSuffix}.exe`])
  }

  const packageFile = path.join(path.dirname(artifacts[0].file), `TestApp-1.1.0${archSuffix}-full.nupkg`)
  const unZipper = new DecompressZip(packageFile)
  const fileDescriptors = await unZipper.getFiles()

  const files = pathSorter(fileDescriptors.map(it => it.path.replace(/\\/g, "/")).filter(it => (!it.startsWith("lib/net45/locales/") || it === "lib/net45/locales/en-US.pak") && !it.endsWith(".psmdcp")))

  // console.log(JSON.stringify(files, null, 2))
  const expectedContents = checkOptions == null || checkOptions.expectedContents == null ? expectedWinContents : checkOptions.expectedContents
  assertThat(files).deepEqual(expectedContents.map(it => {
    if (it === "lib/net45/TestApp.exe") {
      return `lib/net45/${productName.replace(/ /g, "%20")}.exe`
    }
    else {
      return it
    }
  }))

  if (checkOptions == null || checkOptions.expectedContents == null) {
    await unZipper.extractFile(fileDescriptors.filter(it => it.path === "TestApp.nuspec")[0], {
      path: path.dirname(packageFile),
    })
    assertThat((await readFile(path.join(path.dirname(packageFile), "TestApp.nuspec"), "utf8")).replace(/\r\n/g, "\n")).equal(`<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <id>TestApp</id>
    <version>1.1.0</version>
    <title>${productName}</title>
    <authors>Foo Bar</authors>
    <owners>Foo Bar</owners>
    <projectUrl>http://foo.example.com</projectUrl>
    <iconUrl>https://raw.githubusercontent.com/szwacz/electron-boilerplate/master/resources/windows/icon.ico</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Test Application</description>
    <copyright>Copyright Š ${new Date().getFullYear()} Foo Bar</copyright>
  </metadata>
</package>`)
  }
}
开发者ID:alatzidis,项目名称:electron-builder,代码行数:66,代码来源:packTester.ts


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