本文整理汇总了TypeScript中builder-util/out/fs.FileCopier类的典型用法代码示例。如果您正苦于以下问题:TypeScript FileCopier类的具体用法?TypeScript FileCopier怎么用?TypeScript FileCopier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileCopier类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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)
}
}
示例2: copyTestAsset
export function copyTestAsset(name: string, destination: string): Promise<void> {
return fileCopier.copy(path.join(getFixtureDir(), name), destination, undefined)
}