• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript path-sort.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: diff

export function diff(oldList: Array<string>, newList: Array<string>, rootDir: string) {
  const delta: any = {
    added: [],
    deleted: [],
  }
  const deltaMap = new Map<string, ChangeType>()
  // const objHolder = new Set(oldList)
  for (const item of oldList) {
    deltaMap.set(item, ChangeType.REMOVED)
  }

  for (const item of newList) {
    // objHolder.add(item)
    const d = deltaMap.get(item)
    if (d === ChangeType.REMOVED) {
      deltaMap.set(item, ChangeType.NO_CHANGE)
    }
    else {
      deltaMap.set(item, ChangeType.ADDED)
    }
  }

  for (const [item, changeType] of deltaMap.entries()) {
    if (changeType === ChangeType.REMOVED) {
      delta.deleted.push(item.substring(rootDir.length + 1))
    }
    else if (changeType === ChangeType.ADDED) {
      delta.added.push(item.substring(rootDir.length + 1))
    }
  }

  delta.added = pathSorter(delta.added)
  delta.deleted = pathSorter(delta.deleted)
  return delta
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:35,代码来源:wine.ts


示例2: exec

  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


示例3: exec

  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: getContents

async function getContents(packageFile: string) {
  const result = await execShell(`ar p '${packageFile}' data.tar.xz | ${await getTarExecutable()} -t -I'${path7x}'`, {
    maxBuffer: 10 * 1024 * 1024,
    env: {
      ...process.env,
      SZA_PATH: path7za,
    }
  })
  return pathSorter(parseFileList(result, true)
    .filter(it => !(it.includes(`/locales/`) || it.includes(`/libgcrypt`)))
  )
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:12,代码来源:packTester.ts


示例5: getContents

async function getContents(packageFile: string) {
  // without LC_CTYPE dpkg can returns encoded unicode symbols
  const result = await execShell(`ar p '${packageFile}' data.tar.gz | ${await getTarExecutable()} zt`, {
    maxBuffer: 10 * 1024 * 1024,
    env: {
      ...process.env,
      LANG: "en_US.UTF-8",
      LC_CTYPE: "UTF-8"
    }
  })
  return pathSorter(parseFileList(result, true)
    .filter(it => !(it.includes(`/locales/`) || it.includes(`/libgcrypt`)))
  )
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:14,代码来源:packTester.ts


示例6: checkWindowsResult

async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOptions, artifacts: Array<ArtifactCreated>, nameToTarget: Map<string, Target>) {
  const appInfo = packager.appInfo
  let squirrel = false
  for (const target of nameToTarget.keys()) {
    if (target === "squirrel") {
      squirrel = true
      break
    }
  }
  if (!squirrel) {
    return
  }

  const packageFile = artifacts.find(it => it.file!!.endsWith("-full.nupkg"))!.file!!
  const unZipper = new DecompressZip(packageFile!!)
  const fileDescriptors = await unZipper.getFiles()

  // we test app-update.yml separately, don't want to complicate general assert (yes, it is not good that we write app-update.yml for squirrel.windows if we build nsis and squirrel.windows in parallel, but as squirrel.windows is deprecated, it is ok)
  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") && !it.endsWith("app-update.yml")))

  expect(files).toMatchSnapshot()

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


示例7: pathSorter

export const nsisPerMachineInstall = pathSorter([
  "Program Files/TestApp",
  "Program Files/TestApp/1.1.0",
  "Program Files/TestApp/1.1.0/blink_image_resources_200_percent.pak",
  "Program Files/TestApp/1.1.0/content_resources_200_percent.pak",
  "Program Files/TestApp/1.1.0/content_shell.pak",
  "Program Files/TestApp/1.1.0/d3dcompiler_47.dll",
  "Program Files/TestApp/1.1.0/ffmpeg.dll",
  "Program Files/TestApp/1.1.0/icudtl.dat",
  "Program Files/TestApp/1.1.0/libEGL.dll",
  "Program Files/TestApp/1.1.0/libGLESv2.dll",
  "Program Files/TestApp/1.1.0/LICENSE.electron.txt",
  "Program Files/TestApp/1.1.0/LICENSES.chromium.html",
  "Program Files/TestApp/1.1.0/locales",
  "Program Files/TestApp/1.1.0/natives_blob.bin",
  "Program Files/TestApp/1.1.0/node.dll",
  "Program Files/TestApp/1.1.0/resources",
  "Program Files/TestApp/1.1.0/snapshot_blob.bin",
  "Program Files/TestApp/1.1.0/TestApp.exe",
  "Program Files/TestApp/1.1.0/ui_resources_200_percent.pak",
  "Program Files/TestApp/1.1.0/Uninstall TestApp.exe",
  "Program Files/TestApp/1.1.0/views_resources_200_percent.pak",
  "Program Files/TestApp/1.1.0/xinput1_3.dll",
  "Program Files/TestApp/1.1.0/locales/am.pak",
  "Program Files/TestApp/1.1.0/locales/ar.pak",
  "Program Files/TestApp/1.1.0/locales/bg.pak",
  "Program Files/TestApp/1.1.0/locales/bn.pak",
  "Program Files/TestApp/1.1.0/locales/ca.pak",
  "Program Files/TestApp/1.1.0/locales/cs.pak",
  "Program Files/TestApp/1.1.0/locales/da.pak",
  "Program Files/TestApp/1.1.0/locales/de.pak",
  "Program Files/TestApp/1.1.0/locales/el.pak",
  "Program Files/TestApp/1.1.0/locales/en-GB.pak",
  "Program Files/TestApp/1.1.0/locales/en-US.pak",
  "Program Files/TestApp/1.1.0/locales/es-419.pak",
  "Program Files/TestApp/1.1.0/locales/es.pak",
  "Program Files/TestApp/1.1.0/locales/et.pak",
  "Program Files/TestApp/1.1.0/locales/fa.pak",
  "Program Files/TestApp/1.1.0/locales/fake-bidi.pak",
  "Program Files/TestApp/1.1.0/locales/fi.pak",
  "Program Files/TestApp/1.1.0/locales/fil.pak",
  "Program Files/TestApp/1.1.0/locales/fr.pak",
  "Program Files/TestApp/1.1.0/locales/gu.pak",
  "Program Files/TestApp/1.1.0/locales/he.pak",
  "Program Files/TestApp/1.1.0/locales/hi.pak",
  "Program Files/TestApp/1.1.0/locales/hr.pak",
  "Program Files/TestApp/1.1.0/locales/hu.pak",
  "Program Files/TestApp/1.1.0/locales/id.pak",
  "Program Files/TestApp/1.1.0/locales/it.pak",
  "Program Files/TestApp/1.1.0/locales/ja.pak",
  "Program Files/TestApp/1.1.0/locales/kn.pak",
  "Program Files/TestApp/1.1.0/locales/ko.pak",
  "Program Files/TestApp/1.1.0/locales/lt.pak",
  "Program Files/TestApp/1.1.0/locales/lv.pak",
  "Program Files/TestApp/1.1.0/locales/ml.pak",
  "Program Files/TestApp/1.1.0/locales/mr.pak",
  "Program Files/TestApp/1.1.0/locales/ms.pak",
  "Program Files/TestApp/1.1.0/locales/nb.pak",
  "Program Files/TestApp/1.1.0/locales/nl.pak",
  "Program Files/TestApp/1.1.0/locales/pl.pak",
  "Program Files/TestApp/1.1.0/locales/pt-BR.pak",
  "Program Files/TestApp/1.1.0/locales/pt-PT.pak",
  "Program Files/TestApp/1.1.0/locales/ro.pak",
  "Program Files/TestApp/1.1.0/locales/ru.pak",
  "Program Files/TestApp/1.1.0/locales/sk.pak",
  "Program Files/TestApp/1.1.0/locales/sl.pak",
  "Program Files/TestApp/1.1.0/locales/sr.pak",
  "Program Files/TestApp/1.1.0/locales/sv.pak",
  "Program Files/TestApp/1.1.0/locales/sw.pak",
  "Program Files/TestApp/1.1.0/locales/ta.pak",
  "Program Files/TestApp/1.1.0/locales/te.pak",
  "Program Files/TestApp/1.1.0/locales/th.pak",
  "Program Files/TestApp/1.1.0/locales/tr.pak",
  "Program Files/TestApp/1.1.0/locales/uk.pak",
  "Program Files/TestApp/1.1.0/locales/vi.pak",
  "Program Files/TestApp/1.1.0/locales/zh-CN.pak",
  "Program Files/TestApp/1.1.0/locales/zh-TW.pak",
  "Program Files/TestApp/1.1.0/resources/app.asar",
  "Program Files/TestApp/1.1.0/resources/electron.asar",
  "Program Files/TestApp/1.1.0/resources/foo.ico",
  "users/Public/Desktop/TestApp.lnk",
  "users/Public/Start Menu/Programs/TestApp.lnk"
])
开发者ID:heinzbeinz,项目名称:electron-builder,代码行数:83,代码来源:expectedContents.ts


示例8: assertPack

test("extraResources - one-package", async () => {
  for (let platform of [process.platform === "win32" ? Platform.WINDOWS : Platform.LINUX]) {
    const osName = platform.buildConfigurationKey

    const winDirPrefix = "lib/net45/resources/"

    //noinspection SpellCheckingInspection
    await assertPack("test-app-one", {
      // to check NuGet package
      targets: platform.createTarget(platform === Platform.WINDOWS ? null : DIR_TARGET),
      devMetadata: {
        build: {
          asar: true,
        },
      },
    }, {
      projectDirCreated: projectDir => {
        return BluebirdPromise.all([
          modifyPackageJson(projectDir, data => {
            data.build.extraResources = [
              "foo",
              "bar/hello.txt",
              "bar/${arch}.txt",
              "${os}/${arch}.txt",
            ]

            data.build[osName] = {
              extraResources: [
                "platformSpecificR"
              ],
              extraFiles: [
                "platformSpecificF"
              ],
            }
          }),
          outputFile(path.join(projectDir, "foo/nameWithoutDot"), "nameWithoutDot"),
          outputFile(path.join(projectDir, "bar/hello.txt"), "data"),
          outputFile(path.join(projectDir, `bar/${process.arch}.txt`), "data"),
          outputFile(path.join(projectDir, `${osName}/${process.arch}.txt`), "data"),
          outputFile(path.join(projectDir, "platformSpecificR"), "platformSpecificR"),
          outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"),
        ])
      },
      packed: async context => {
        const base = path.join(context.outDir, platform.buildConfigurationKey + `${platform === Platform.MAC ? "" : "-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 assertThat(path.join(resourcesDir, "foo")).isDirectory()
        await assertThat(path.join(appDir, "foo")).doesNotExist()

        await assertThat(path.join(resourcesDir, "foo", "nameWithoutDot")).isFile()
        await assertThat(path.join(appDir, "foo", "nameWithoutDot")).doesNotExist()

        await assertThat(path.join(resourcesDir, "bar", "hello.txt")).isFile()
        await assertThat(path.join(resourcesDir, "bar", `${process.arch}.txt`)).isFile()
        await assertThat(path.join(appDir, "bar", `${process.arch}.txt`)).doesNotExist()

        await assertThat(path.join(resourcesDir, osName, `${process.arch}.txt`)).isFile()
        await assertThat(path.join(resourcesDir, "platformSpecificR")).isFile()
        await assertThat(path.join(resourcesDir, "ignoreMe.txt")).doesNotExist()
      },
      expectedContents: platform === Platform.WINDOWS ? pathSorter(expectedWinContents.concat(
        winDirPrefix + "bar/hello.txt",
        winDirPrefix + "bar/x64.txt",
        winDirPrefix + "foo/nameWithoutDot",
        winDirPrefix + "platformSpecificR",
        winDirPrefix + "win/x64.txt"
      )) : null,
    })
  }
})
开发者ID:Icenium,项目名称:electron-builder,代码行数:75,代码来源:globTest.ts


示例9: assertPack

test("extraResources", async () => {
  for (const platform of getPossiblePlatforms().keys()) {
    const osName = platform.buildConfigurationKey
    const winDirPrefix = "lib/net45/resources/"

    //noinspection SpellCheckingInspection
    await assertPack("test-app-one", {
      // to check NuGet package
      targets: platform.createTarget(platform === Platform.WINDOWS ? "squirrel" : DIR_TARGET),
    }, {
      projectDirCreated: projectDir => {
        return BluebirdPromise.all([
          modifyPackageJson(projectDir, data => {
            data.build.extraResources = [
              "foo",
              "bar/hello.txt",
              "bar/${arch}.txt",
              "${os}/${arch}.txt",
            ]

            data.build[osName] = {
              extraResources: [
                "platformSpecificR"
              ],
              extraFiles: [
                "platformSpecificF"
              ],
            }
          }),
          outputFile(path.join(projectDir, "foo/nameWithoutDot"), "nameWithoutDot"),
          outputFile(path.join(projectDir, "bar/hello.txt"), "data"),
          outputFile(path.join(projectDir, `bar/${process.arch}.txt`), "data"),
          outputFile(path.join(projectDir, `${osName}/${process.arch}.txt`), "data"),
          outputFile(path.join(projectDir, "platformSpecificR"), "platformSpecificR"),
          outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"),
        ])
      },
      packed: context => {
        const base = path.join(context.outDir, `${platform.buildConfigurationKey}${platform === Platform.MAC ? "" : "-unpacked"}`)
        let resourcesDir = path.join(base, "resources")
        if (platform === Platform.MAC) {
          resourcesDir = path.join(base, `${context.packager.appInfo.productFilename}.app`, "Contents", "Resources")
        }

        return BluebirdPromise.all([
          assertThat(path.join(resourcesDir, "foo")).isDirectory(),
          assertThat(path.join(resourcesDir, "foo", "nameWithoutDot")).isFile(),
          assertThat(path.join(resourcesDir, "bar", "hello.txt")).isFile(),
          assertThat(path.join(resourcesDir, "bar", `${process.arch}.txt`)).isFile(),
          assertThat(path.join(resourcesDir, osName, `${process.arch}.txt`)).isFile(),
          assertThat(path.join(resourcesDir, "platformSpecificR")).isFile(),
          assertThat(path.join(resourcesDir, "ignoreMe.txt")).doesNotExist(),
        ])
      },
      expectedContents: platform === Platform.WINDOWS ? pathSorter(expectedWinContents.concat(
        winDirPrefix + "bar/hello.txt",
        winDirPrefix + "bar/x64.txt",
        winDirPrefix + "foo/nameWithoutDot",
        winDirPrefix + "platformSpecificR",
        winDirPrefix + "win/x64.txt"
      )) : null,
    })
  }
})
开发者ID:heinzbeinz,项目名称:electron-builder,代码行数:64,代码来源:filesTest.ts


示例10: assertPack

test.ifNotCiWin("extraResources - one-package", () => {
  const platform = process.platform === "win32" ? Platform.WINDOWS : Platform.LINUX
  const osName = platform.buildConfigurationKey

  const winDirPrefix = "lib/net45/resources/"

  //noinspection SpellCheckingInspection
  return assertPack("test-app-one", {
    // to check NuGet package
    targets: platform.createTarget(platform === Platform.WINDOWS ? "squirrel" : DIR_TARGET),
    config: {
      asar: true,
      extraResources: [
        "foo",
        "bar/hello.txt",
        "bar/${arch}.txt",
        "${os}/${arch}.txt",
        "executable*",
      ],
      [osName]: {
        extraResources: [
          "platformSpecificR"
        ],
        extraFiles: [
          "platformSpecificF"
        ],
      },
    },
  }, {
    projectDirCreated: projectDir => {
      return BluebirdPromise.all([
        outputFile(path.join(projectDir, "foo/nameWithoutDot"), "nameWithoutDot"),
        outputFile(path.join(projectDir, "bar/hello.txt"), "data", {mode: "400"}),
        outputFile(path.join(projectDir, `bar/${process.arch}.txt`), "data"),
        outputFile(path.join(projectDir, `${osName}/${process.arch}.txt`), "data"),
        outputFile(path.join(projectDir, "platformSpecificR"), "platformSpecificR"),
        outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"),
        outputFile(path.join(projectDir, "executable"), "executable", {mode: "755"}),
        outputFile(path.join(projectDir, "executableOnlyOwner"), "executable", {mode: "740"}),
      ])
    },
    packed: async context => {
      const base = path.join(context.outDir, platform.buildConfigurationKey + `${platform === Platform.MAC ? "" : "-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")
    },
    expectedContents: platform === Platform.WINDOWS ? pathSorter(expectedWinContents.concat(
      winDirPrefix + "bar/hello.txt",
      winDirPrefix + "bar/x64.txt",
      winDirPrefix + "foo/nameWithoutDot",
      winDirPrefix + "platformSpecificR",
      winDirPrefix + "win/x64.txt"
    )) : null,
  })
})
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:81,代码来源:filesTest.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript path.win32类代码示例发布时间:2022-05-25
下一篇:
TypeScript path.scope类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap