本文整理汇总了TypeScript中fs-extra-p.copy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript copy函数的具体用法?TypeScript copy怎么用?TypeScript copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Set
.then((it: any) => {
const devDeps = Object.keys(it.devDependencies)
const filtered = new Set()
/*eslint prefer-const: 0*/
for (let name of devDeps) {
filtered.add(path.join(rootDir, "node_modules", name))
}
filtered.add(path.join(rootDir, "node_modules", ".bin"))
return fs.copy(path.join(rootDir, "node_modules"), testNodeModules, {
filter: it => {
if (it.includes("node_modules" + path.sep + "babel-")) {
return false
}
return !filtered.has(it)
}
})
})
示例2: copyDependencies
// npm is very slow and not reliable - so, just copy and then prune dev dependencies
async function copyDependencies() {
await emptyDir(testNodeModules)
const devDeps = Object.keys((await readJson(path.join(rootDir, "package.json"), "utf-8")).devDependencies)
const filtered = new Set()
/*eslint prefer-const: 0*/
for (let name of devDeps) {
filtered.add(path.join(rootDir, "node_modules", name))
}
filtered.add(path.join(rootDir, "node_modules", ".bin"))
return copy(path.join(rootDir, "node_modules"), testNodeModules, {
filter: it => {
if (it.includes("node_modules" + path.sep + "babel-")) {
return false
}
return !filtered.has(it)
}
})
}
示例3: assertPack
export async function assertPack(fixtureName: string, platform: string | Array<string>, packagerOptions?: PackagerOptions, useTempDir?: boolean, tempDirCreated?: (projectDir: string) => Promise<any>) {
let projectDir = path.join(__dirname, "..", "..", "fixtures", fixtureName)
// const isDoNotUseTempDir = platform === "darwin"
const customTmpDir = process.env.TEST_APP_TMP_DIR
if (useTempDir) {
// non-osx test uses the same dir as osx test, but we cannot share node_modules (because tests executed in parallel)
const dir = customTmpDir == null ? path.join(tmpdir(), tmpDirPrefix + fixtureName + "-" + tmpDirCounter++) : path.resolve(customTmpDir)
if (customTmpDir != null) {
console.log("Custom temp dir used: %s", customTmpDir)
}
await emptyDir(dir)
await copy(projectDir, dir, {
filter: it => {
const basename = path.basename(it)
return basename !== "dist" && basename !== "node_modules" && basename[0] !== "."
}
})
projectDir = dir
}
try {
if (tempDirCreated != null) {
await tempDirCreated(projectDir)
}
const platforms = Array.isArray(platform) ? platform : [platform]
await packAndCheck(projectDir, platforms, packagerOptions)
}
finally {
if (useTempDir && customTmpDir == null) {
try {
await remove(projectDir)
}
catch (e) {
console.warn("Cannot delete temporary directory " + projectDir + ": " + (e.stack || e))
}
}
}
}
示例4: createApp
export async function createApp(opts: ElectronPackagerOptions, appOutDir: string, initializeApp: () => Promise<any>) {
const appInfo = opts.appInfo
const appFilename = appInfo.productFilename
const contentsPath = path.join(appOutDir, "Electron.app", "Contents")
const frameworksPath = path.join(contentsPath, "Frameworks")
const appPlistFilename = path.join(contentsPath, "Info.plist")
const helperPlistFilename = path.join(frameworksPath, "Electron Helper.app", "Contents", "Info.plist")
const helperEHPlistFilename = path.join(frameworksPath, "Electron Helper EH.app", "Contents", "Info.plist")
const helperNPPlistFilename = path.join(frameworksPath, "Electron Helper NP.app", "Contents", "Info.plist")
const result = await BluebirdPromise.all<any | n>([
initializeApp(),
BluebirdPromise.map<any | null>([appPlistFilename, helperPlistFilename, helperEHPlistFilename, helperNPPlistFilename, opts["extend-info"]], it => it == null ? it : readFile(it, "utf8"))
])
const fileContents: Array<string> = result[1]!
const appPlist = parsePlist(fileContents[0])
const helperPlist = parsePlist(fileContents[1])
const helperEHPlist = parsePlist(fileContents[2])
const helperNPPlist = parsePlist(fileContents[3])
// If an extend-info file was supplied, copy its contents in first
if (fileContents[4] != null) {
Object.assign(appPlist, parsePlist(fileContents[4]))
}
// Now set fields based on explicit options
const appBundleIdentifier = filterCFBundleIdentifier(appInfo.id)
const helperBundleIdentifier = filterCFBundleIdentifier(opts["helper-bundle-id"] || `${appBundleIdentifier}.helper`)
const buildVersion = appInfo.buildVersion
const appCategoryType = opts["app-category-type"]
const humanReadableCopyright = appInfo.copyright
appPlist.CFBundleDisplayName = appInfo.productName
appPlist.CFBundleIdentifier = appBundleIdentifier
appPlist.CFBundleName = appInfo.productName
helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
helperPlist.CFBundleIdentifier = helperBundleIdentifier
appPlist.CFBundleExecutable = appFilename
helperPlist.CFBundleName = appInfo.productName
helperPlist.CFBundleExecutable = `${appFilename} Helper`
helperEHPlist.CFBundleDisplayName = `${appFilename} Helper EH`
helperEHPlist.CFBundleIdentifier = `${helperBundleIdentifier}.EH`
helperEHPlist.CFBundleName = `${appInfo.productName} Helper EH`
helperEHPlist.CFBundleExecutable = `${appFilename} Helper EH`
helperNPPlist.CFBundleDisplayName = `${appInfo.productName} Helper NP`
helperNPPlist.CFBundleIdentifier = `${helperBundleIdentifier}.NP`
helperNPPlist.CFBundleName = `${appInfo.productName} Helper NP`
helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`
if (appInfo.version != null) {
appPlist.CFBundleShortVersionString = appPlist.CFBundleVersion = appInfo.version
}
if (buildVersion != null) {
appPlist.CFBundleVersion = buildVersion
}
if (opts.protocols && opts.protocols.length) {
appPlist.CFBundleURLTypes = opts.protocols.map(function (protocol: any) {
return {
CFBundleURLName: protocol.name,
CFBundleURLSchemes: [].concat(protocol.schemes)
}
})
}
if (appCategoryType) {
appPlist.LSApplicationCategoryType = appCategoryType
}
if (humanReadableCopyright) {
appPlist.NSHumanReadableCopyright = humanReadableCopyright
}
const promises: Array<BluebirdPromise<any | n>> = [
writeFile(appPlistFilename, buildPlist(appPlist)),
writeFile(helperPlistFilename, buildPlist(helperPlist)),
writeFile(helperEHPlistFilename, buildPlist(helperEHPlist)),
writeFile(helperNPPlistFilename, buildPlist(helperNPPlist)),
doRename(path.join(contentsPath, "MacOS"), "Electron", appPlist.CFBundleExecutable)
]
if (opts.icon != null) {
promises.push(copy(opts.icon, path.join(contentsPath, "Resources", appPlist.CFBundleIconFile)))
}
await BluebirdPromise.all(promises)
await moveHelpers(frameworksPath, appFilename)
await rename(path.dirname(contentsPath), path.join(appOutDir, `${appFilename}.app`))
}
示例5: copy
return await BluebirdPromise.map(await this.getExtraResources(arch), it => copy(path.join(this.projectDir, it), path.join(resourcesDir, it)))
示例6: copy
.then(() => copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32")))
示例7: copy
tempDirCreated: projectDir => {
installerHeaderPath = path.join(projectDir, "build", "installerHeader.bmp")
return copy(getTestAsset("installerHeader.bmp"), installerHeaderPath)
}
示例8: copyFiltered
export function copyFiltered(src: string, destination: string, filter: (file: string) => boolean, dereference: boolean): Promise<any> {
return copy(src, destination, {
dereference: dereference,
filter: filter
})
}
示例9: unlink
projectDirCreated: projectDir => Promise.all([
unlink(path.join(projectDir, "build", "icon.icns")),
unlink(path.join(projectDir, "build", "icon.ico")),
copy(path.join(projectDir, "build", "icons", "512x512.png"), path.join(projectDir, "build", "icon.png"))
.then(() => remove(path.join(projectDir, "build", "icons")))
]),