本文整理匯總了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)
}
}