本文整理汇总了TypeScript中builder-util.debug7zArgs函数的典型用法代码示例。如果您正苦于以下问题:TypeScript debug7zArgs函数的具体用法?TypeScript debug7zArgs怎么用?TypeScript debug7zArgs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug7zArgs函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: unpack
async function unpack(packager: PlatformPackager<any>, out: string, platform: string, options: InternalElectronDownloadOptions) {
let dist: string | null | undefined = packager.config.electronDist
if (dist != null) {
const zipFile = `electron-v${options.version}-${platform}-${options.arch}.zip`
const resolvedDist = path.resolve(packager.projectDir, dist)
if ((await statOrNull(path.join(resolvedDist, zipFile))) != null) {
options.cache = resolvedDist
dist = null
}
}
if (dist == null) {
const zipPath = (await BluebirdPromise.all<any>([
packager.info.electronDownloader(options),
emptyDir(out)
]))[0]
if (process.platform === "darwin" || isEnvTrue(process.env.USE_UNZIP)) {
// on mac unzip faster than 7za (1.1 sec vs 1.6 see)
await exec("unzip", ["-oqq", "-d", out, zipPath])
}
else {
await spawn(path7za, debug7zArgs("x").concat(zipPath, "-aoa", `-o${out}`))
if (platform === "linux") {
// https://github.com/electron-userland/electron-builder/issues/786
// fix dir permissions â opposite to extract-zip, 7za creates dir with no-access for other users, but dir must be readable for non-root users
await BluebirdPromise.all([
chmod(path.join(out, "locales"), "0755"),
chmod(path.join(out, "resources"), "0755")
])
}
}
}
else {
const source = packager.getElectronSrcDir(dist)
const destination = packager.getElectronDestinationDir(out)
log.info({source, destination}, "copying Electron")
await emptyDir(out)
await copyDir(source, destination, {
isUseHardLink: DO_NOT_USE_HARD_LINKS,
})
}
}
示例2: tar
export async function tar(compression: CompressionLevel | any | any, format: string, outFile: string, dirToArchive: string, isMacApp: boolean, tempDirManager: TmpDir): Promise<void> {
const tarFile = await tempDirManager.getTempFile({suffix: ".tar"})
const tarArgs = debug7zArgs("a")
tarArgs.push(tarFile)
tarArgs.push(path.basename(dirToArchive))
await BluebirdPromise.all([
exec(path7za, tarArgs, {cwd: path.dirname(dirToArchive)}),
// remove file before - 7z doesn't overwrite file, but update
unlinkIfExists(outFile),
])
if (!isMacApp) {
await exec(path7za, ["rn", tarFile, path.basename(dirToArchive), path.basename(outFile, `.${format}`)])
}
if (format === "tar.lz") {
// noinspection SpellCheckingInspection
let lzipPath = "lzip"
if (process.platform === "darwin") {
lzipPath = path.join(await getLinuxToolsPath(), "bin", lzipPath)
}
await exec(lzipPath, [compression === "store" ? "-1" : "-9", "--keep" /* keep (don't delete) input files */, tarFile])
// bloody lzip creates file in the same dir where input file with postfix `.lz`, option --output doesn't work
await move(`${tarFile}.lz`, outFile)
return
}
const args = compute7zCompressArgs(format === "tar.xz" ? "xz" : (format === "tar.bz2" ? "bzip2" : "gzip"), {
isRegularFile: true,
method: "DEFAULT",
compression,
})
args.push(outFile, tarFile)
await exec(path7za, args, {
cwd: path.dirname(dirToArchive),
}, debug7z.enabled)
}
示例3: unpack
async function unpack(packager: PlatformPackager<any>, out: string, platform: string, options: InternalElectronDownloadOptions) {
let dist: string | null | undefined = packager.config.electronDist
if (dist != null) {
const zipFile = `electron-v${options.version}-${platform}-${options.arch}.zip`
const resolvedDist = path.resolve(packager.projectDir, dist)
if ((await statOrNull(path.join(resolvedDist, zipFile))) != null) {
options.cache = resolvedDist
dist = null
}
}
if (dist == null) {
const zipPath = (await BluebirdPromise.all<any>([
downloadElectron(options),
emptyDir(out)
]))[0]
await spawn(path7za, debug7zArgs("x").concat(zipPath, "-aoa", `-o${out}`))
}
else {
const source = packager.getElectronSrcDir(dist)
const destination = packager.getElectronDestinationDir(out)
log(`Copying Electron from "${source}" to "${destination}"`)
await emptyDir(out)
await copyDir(source, destination, null, null, DO_NOT_USE_HARD_LINKS)
}
if (platform === "linux") {
// https://github.com/electron-userland/electron-builder/issues/786
// fix dir permissions â opposite to extract-zip, 7za creates dir with no-access for other users, but dir must be readable for non-root users
await BluebirdPromise.all([
chmod(path.join(out, "locales"), "0755"),
chmod(path.join(out, "resources"), "0755")
])
}
}
示例4: compute7zCompressArgs
export function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {
let storeOnly = options.compression === "store"
const args = debug7zArgs("a")
let isLevelSet = false
if (process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL != null) {
storeOnly = false
args.push(`-mx=${process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL}`)
isLevelSet = true
}
if (format === "zip" && options.compression === "maximum") {
// http://superuser.com/a/742034
args.push("-mfb=258", "-mpass=15")
}
if (!isLevelSet && !storeOnly) {
args.push("-mx=9")
}
if (options.dictSize != null) {
args.push(`-md=${options.dictSize}m`)
}
// https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm#7Z
// https://stackoverflow.com/questions/27136783/7zip-produces-different-output-from-identical-input
// tc and ta are off by default, but to be sure, we explicitly set it to off
// disable "Stores NTFS timestamps for files: Modification time, Creation time, Last access time." to produce the same archive for the same data
if (!options.isRegularFile) {
args.push("-mtc=off")
}
if (format === "7z" || format.endsWith(".7z")) {
if (options.solid === false) {
args.push("-ms=off")
}
if (options.isArchiveHeaderCompressed === false) {
args.push("-mhc=off")
}
// args valid only for 7z
// -mtm=off disable "Stores last Modified timestamps for files."
args.push("-mtm=off", "-mta=off")
}
if (options.method != null) {
if (options.method !== "DEFAULT") {
args.push(`-mm=${options.method}`)
}
}
else if (format === "zip" || storeOnly) {
args.push(`-mm=${storeOnly ? "Copy" : "Deflate"}`)
}
if (format === "zip") {
// -mcu switch: 7-Zip uses UTF-8, if there are non-ASCII symbols.
// because default mode: 7-Zip uses UTF-8, if the local code page doesn't contain required symbols.
// but archive should be the same regardless where produced
args.push("-mcu")
}
return args
}