本文整理汇总了TypeScript中fs-extra-p.chmod函数的典型用法代码示例。如果您正苦于以下问题:TypeScript chmod函数的具体用法?TypeScript chmod怎么用?TypeScript chmod使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chmod函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: unpack
async function unpack(packager: PlatformPackager<any>, out: string, platform: string, options: any) {
const dist = packager.config.electronDist
if (dist == null) {
const zipPath = (await BluebirdPromise.all<any>([
downloadElectron(options),
emptyDir(out)
]))[0]
await spawn(path7za, debug7zArgs("x").concat(zipPath, `-o${out}`))
}
else {
const source = packager.getElectronSrcDir(dist)
const destination = packager.getElectronDestDir(out)
log(`Copying Electron from "${source}" to "${destination}"`)
await emptyDir(out)
await copyDir(source, destination)
}
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")
])
}
}
开发者ID:djpereira,项目名称:electron-builder,代码行数:27,代码来源:dirPackager.ts
示例2: async
await this.executeDownload(downloadOptions, fileInfo, async (tempDir, destinationFile) => {
installerPath = destinationFile
const oldFile = process.env.APPIMAGE!!
if (oldFile == null) {
throw newError("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND")
}
let isDownloadFull = false
try {
await new FileWithEmbeddedBlockMapDifferentialDownloader(fileInfo.info, this.httpExecutor, {
newUrl: fileInfo.url.href,
oldFile,
logger: this._logger,
newFile: installerPath,
useMultipleRangeRequest: provider.useMultipleRangeRequest,
requestHeaders,
})
.download()
}
catch (e) {
this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)
// during test (developer machine mac) we must throw error
isDownloadFull = process.platform === "linux"
}
if (isDownloadFull) {
await this.httpExecutor.download(fileInfo.url.href, installerPath, downloadOptions)
}
await chmod(installerPath, 0o755)
})
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:32,代码来源:AppImageUpdater.ts
示例3: async
task: async (updateFile, downloadOptions) => {
const oldFile = process.env.APPIMAGE!!
if (oldFile == null) {
throw newError("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND")
}
let isDownloadFull = false
try {
await new FileWithEmbeddedBlockMapDifferentialDownloader(fileInfo.info, this.httpExecutor, {
newUrl: fileInfo.url,
oldFile,
logger: this._logger,
newFile: updateFile,
isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,
requestHeaders: downloadUpdateOptions.requestHeaders,
})
.download()
}
catch (e) {
this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)
// during test (developer machine mac) we must throw error
isDownloadFull = process.platform === "linux"
}
if (isDownloadFull) {
await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)
}
await chmod(updateFile, 0o755)
},
开发者ID:electron-userland,项目名称:electron-builder,代码行数:30,代码来源:AppImageUpdater.ts
示例4: build
async build(appOutDir: string, arch: Arch): Promise<any> {
const packager = this.packager
// avoid spaces in the file name
const image = path.join(this.outDir, packager.generateName("AppImage", arch, true))
const appInfo = packager.appInfo
await unlinkIfExists(image)
const appImagePath = await appImagePathPromise
const args = [
"-joliet", "on",
"-volid", "AppImage",
"-dev", image,
"-padding", "0",
"-map", appOutDir, "/usr/bin",
"-map", path.join(__dirname, "..", "..", "templates", "linux", "AppRun.sh"), `/AppRun`,
"-map", await this.desktopEntry, `/${appInfo.name}.desktop`,
"-move", `/usr/bin/${appInfo.productFilename}`, `/usr/bin/${appInfo.name}`,
]
for (let [from, to] of (await this.helper.icons)) {
args.push("-map", from, `/usr/share/icons/default/${to}`)
}
// must be after this.helper.icons call
if (this.helper.maxIconPath == null) {
throw new Error("Icon is not provided")
}
args.push("-map", this.helper.maxIconPath, "/.DirIcon")
args.push("-chown_r", "0", "/", "--")
args.push("-zisofs", `level=${packager.devMetadata.build.compression === "store" ? "0" : "9"}:block_size=128k:by_magic=off`)
args.push("set_filter_r", "--zisofs", "/")
await exec(process.env.USE_SYSTEM_FPM === "true" || process.arch !== "x64" ? "xorriso" : path.join(appImagePath, "xorriso"), args)
await new BluebirdPromise((resolve, reject) => {
const rd = createReadStream(path.join(appImagePath, arch === Arch.ia32 ? "32" : "64", "runtime"))
rd.on("error", reject)
const wr = createWriteStream(image, {flags: "r+"})
wr.on("error", reject)
wr.on("finish", resolve)
rd.pipe(wr)
})
const fd = await open(image, "r+")
try {
const magicData = new Buffer([0x41, 0x49, 0x01])
await write(fd, magicData, 0, magicData.length, 8)
}
finally {
await close(fd)
}
await chmod(image, "0755")
packager.dispatchArtifactCreated(image, packager.generateName("AppImage", arch, true))
}
开发者ID:SimplyAhmazing,项目名称:electron-builder,代码行数:57,代码来源:appImage.ts
示例5: 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,
})
}
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:43,代码来源:dirPackager.ts
示例6: unpackElectron
export async function unpackElectron(packager: PlatformPackager<any>, out: string, platform: string, arch: string, electronVersion: string) {
const electronDist = packager.config.electronDist
if (electronDist == null) {
const zipPath = (await BluebirdPromise.all<any>([
downloadElectron(createDownloadOpts(packager.config, platform, arch, electronVersion)),
emptyDir(out)
]))[0]
await spawn(path7za, debug7zArgs("x").concat(zipPath, `-o${out}`))
}
else {
await emptyDir(out)
await copyDir(path.resolve(packager.info.projectDir, electronDist, "Electron.app"), path.join(out, "Electron.app"))
}
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")
])
}
}
开发者ID:heinzbeinz,项目名称:electron-builder,代码行数:24,代码来源:dirPackager.ts
示例7: 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, `-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")
])
}
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:36,代码来源:dirPackager.ts
示例8: chmod
.then(() => chmod(dest, stats.mode))
开发者ID:electron-userland,项目名称:electron-builder,代码行数:1,代码来源:fs.ts
示例9: build
async build(appOutDir: string, arch: Arch): Promise<any> {
const packager = this.packager
const image = path.join(this.outDir, packager.generateName(null, arch, true))
const appInfo = packager.appInfo
await unlinkIfExists(image)
const appImagePath = await appImagePathPromise
const args = [
"-joliet", "on",
"-volid", "AppImage",
"-dev", image,
"-padding", "0",
"-map", appOutDir, "/usr/bin",
"-map", path.join(__dirname, "..", "..", "templates", "linux", "AppRun.sh"), `/AppRun`,
"-map", await this.desktopEntry, `/${appInfo.name}.desktop`,
"-move", `/usr/bin/${appInfo.productFilename}`, "/usr/bin/app",
]
for (let [from, to] of (await this.helper.icons)) {
args.push("-map", from, `/usr/share/icons/default/${to}`)
}
// must be after this.helper.icons call
if (this.helper.maxIconPath == null) {
throw new Error("Icon is not provided")
}
args.push("-map", this.helper.maxIconPath, "/.DirIcon")
// args.push("-zisofs", `level=0:block_size=128k:by_magic=off`, "-chown_r", "0")
// args.push("/", "--", "set_filter_r", "--zisofs", "/")
await exec(process.platform === "darwin" ? path.join(appImagePath, "xorriso") : "xorriso", args)
await new BluebirdPromise((resolve, reject) => {
const rd = createReadStream(path.join(appImagePath, arch === Arch.ia32 ? "32" : "64", "runtime"))
rd.on("error", reject)
const wr = createWriteStream(image)
wr.on("error", reject)
wr.on("finish", resolve)
rd.pipe(wr)
})
const fd = await open(image, "r+")
try {
const magicData = new Buffer([0x41, 0x49, 0x01])
await write(fd, magicData, 0, magicData.length, 8)
}
finally {
await close(fd)
}
await chmod(image, "0755")
// we archive because you cannot distribute exe as is - e.g. Ubuntu clear exec flag and user cannot just click on AppImage to run
// also, LZMA compression - 29MB vs zip 42MB
// we use slow xz instead of 7za because 7za doesn't preserve exec file permissions for xz
await spawn("xz", ["--x86", "--lzma2", "--compress", "--force", packager.devMetadata.build.compression === "store" ? "-0" : "-9e", image], {
cwd: path.dirname(image),
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
})
packager.dispatchArtifactCreated(image)
}
开发者ID:reactsnipp,项目名称:electron-builder,代码行数:62,代码来源:appImage.ts
示例10: chmod
.then((): any => {
if (stats != null) {
return chmod(dest, stats.mode)
}
return null
})
开发者ID:jwheare,项目名称:electron-builder,代码行数:6,代码来源:fs.ts
注:本文中的fs-extra-p.chmod函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论