本文整理匯總了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
}
示例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(),
])
}
示例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(),
])
}
示例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`)))
)
}
示例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`)))
)
}
示例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>`)
}
}
示例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"
])
示例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,
})
}
})
示例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,
})
}
})
示例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,
})
})