本文整理汇总了TypeScript中fs-extra-p.readlink函数的典型用法代码示例。如果您正苦于以下问题:TypeScript readlink函数的具体用法?TypeScript readlink怎么用?TypeScript readlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readlink函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: copyAppFiles
export async function copyAppFiles(fileSet: FileSet, packager: Packager) {
const metadata = fileSet.metadata
const transformedFiles = fileSet.transformedFiles
// search auto unpacked dir
const unpackedDirs = new Set<string>()
const taskManager = new AsyncTaskManager(packager.cancellationToken)
const dirToCreateForUnpackedFiles = new Set<string>(unpackedDirs)
const fileCopier = new FileCopier()
const links: Array<Link> = []
for (let i = 0, n = fileSet.files.length; i < n; i++) {
const file = fileSet.files[i]
const stat = metadata.get(file)
if (stat == null) {
// dir
continue
}
const relativePath = file.replace(fileSet.src, fileSet.destination)
if (stat.isFile()) {
const fileParent = path.dirname(file)
// const dirNode = this.fs.getOrCreateNode(this.getRelativePath(fileParent))
const newData = transformedFiles == null ? null : transformedFiles[i] as string | Buffer
if (newData != null) {
transformedFiles[i] = null
}
if (!dirToCreateForUnpackedFiles.has(fileParent)) {
dirToCreateForUnpackedFiles.add(fileParent)
await ensureDir(fileParent.replace(fileSet.src, fileSet.destination))
}
taskManager.addTask(copyFileOrData(fileCopier, newData, file, relativePath, stat))
if (taskManager.tasks.length > MAX_FILE_REQUESTS) {
await taskManager.awaitTasks()
}
}
else if (stat.isSymbolicLink()) {
links.push({file: relativePath, link: await readlink(file)})
}
}
if (taskManager.tasks.length > MAX_FILE_REQUESTS) {
await taskManager.awaitTasks()
}
if (links.length > 0) {
BluebirdPromise.map(links, it => symlink(it.link, it.file), CONCURRENCY)
}
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:50,代码来源:appFileCopier.ts
示例2: copyAppFiles
export async function copyAppFiles(fileSet: ResolvedFileSet, packager: Packager) {
const metadata = fileSet.metadata
const transformedFiles = fileSet.transformedFiles
// search auto unpacked dir
const taskManager = new AsyncTaskManager(packager.cancellationToken)
const createdParentDirs = new Set<string>()
const fileCopier = new FileCopier()
const links: Array<Link> = []
for (let i = 0, n = fileSet.files.length; i < n; i++) {
const sourceFile = fileSet.files[i]
const stat = metadata.get(sourceFile)
if (stat == null) {
// dir
continue
}
const destinationFile = getDestinationPath(sourceFile, fileSet)
if (stat.isFile()) {
const newData = transformedFiles == null ? null : transformedFiles[i] as string | Buffer
if (newData != null) {
transformedFiles[i] = null
}
const fileParent = path.dirname(destinationFile)
if (!createdParentDirs.has(fileParent)) {
createdParentDirs.add(fileParent)
await ensureDir(fileParent)
}
taskManager.addTask(copyFileOrData(fileCopier, newData, sourceFile, destinationFile, stat))
if (taskManager.tasks.length > MAX_FILE_REQUESTS) {
await taskManager.awaitTasks()
}
}
else if (stat.isSymbolicLink()) {
links.push({file: destinationFile, link: await readlink(sourceFile)})
}
}
if (taskManager.tasks.length > MAX_FILE_REQUESTS) {
await taskManager.awaitTasks()
}
if (links.length > 0) {
BluebirdPromise.map(links, it => symlink(it.link, it.file), CONCURRENCY)
}
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:47,代码来源:appFileCopier.ts
示例3: async
consume: async (file, stat, parent) => {
if (!stat.isFile() && !stat.isSymbolicLink()) {
return
}
if (!createdSourceDirs.has(parent)) {
await ensureDir(parent.replace(src, destination))
createdSourceDirs.add(parent)
}
const destFile = file.replace(src, destination)
if (stat.isFile()) {
await fileCopier.copy(file, destFile, stat)
}
else {
links.push({file: destFile, link: await readlink(file)})
}
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:18,代码来源:fs.ts
示例4: copyAppFiles
export async function copyAppFiles(fileSet: ResolvedFileSet, packager: Packager, transformer: FileTransformer) {
const metadata = fileSet.metadata
// search auto unpacked dir
const taskManager = new AsyncTaskManager(packager.cancellationToken)
const createdParentDirs = new Set<string>()
const fileCopier = new FileCopier(file => {
// https://github.com/electron-userland/electron-builder/issues/3038
return !(isLibOrExe(file) || file.endsWith(".node"))
}, transformer)
const links: Array<Link> = []
for (let i = 0, n = fileSet.files.length; i < n; i++) {
const sourceFile = fileSet.files[i]
const stat = metadata.get(sourceFile)
if (stat == null) {
// dir
continue
}
const destinationFile = getDestinationPath(sourceFile, fileSet)
if (stat.isSymbolicLink()) {
links.push({file: destinationFile, link: await readlink(sourceFile)})
continue
}
const fileParent = path.dirname(destinationFile)
if (!createdParentDirs.has(fileParent)) {
createdParentDirs.add(fileParent)
await ensureDir(fileParent)
}
taskManager.addTask(fileCopier.copy(sourceFile, destinationFile, stat))
if (taskManager.tasks.length > MAX_FILE_REQUESTS) {
await taskManager.awaitTasks()
}
}
if (taskManager.tasks.length > 0) {
await taskManager.awaitTasks()
}
if (links.length > 0) {
await BluebirdPromise.map(links, it => symlink(it.link, it.file), CONCURRENCY)
}
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:44,代码来源:appFileCopier.ts
注:本文中的fs-extra-p.readlink函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论