本文整理汇总了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)
}
}
示例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)
}
}
示例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)})
}
}
示例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)
}
}