本文整理汇总了TypeScript中fs.copyFileSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript copyFileSync函数的具体用法?TypeScript copyFileSync怎么用?TypeScript copyFileSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copyFileSync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: bootstrapSbtProject
function bootstrapSbtProject(buildSbtFileSource: string,
dottyPluginSbtFileSource: string) {
fs.mkdirSync(sbtProjectDir)
fs.appendFileSync(sbtBuildPropertiesFile, `sbt.version=${sbtVersion}`)
fs.copyFileSync(buildSbtFileSource, sbtBuildSbtFile)
fs.copyFileSync(dottyPluginSbtFileSource, path.join(sbtProjectDir, "plugins.sbt"))
}
示例2: syncConfigFiles
private syncConfigFiles(filename: string): void {
const dotfilesPath = join(__dirname, filename)
const vscodePath = join(this.configPath, 'User', filename)
if (!existsSync(vscodePath)) {
console.info(' Using dotfiles version (target is missing)')
copyFileSync(dotfilesPath, vscodePath)
}
if (readFileSync(dotfilesPath).toString() === readFileSync(vscodePath).toString()) {
return
}
const dotfilesStat = statSync(dotfilesPath)
const vscodeStat = statSync(vscodePath)
console.info(`Config file '${filename}' has changed`)
if (dotfilesStat.mtime > vscodeStat.mtime) {
console.info(' Using dotfiles version')
copyFileSync(dotfilesPath, vscodePath)
} else {
console.info(' Updating dotfiles version')
copyFileSync(vscodePath, dotfilesPath)
}
}
示例3: getExtraResource
(async () => {
try {
const options: packager.Options = {
arch: "x64",
asar: true,
dir: ".",
extraResource: await getExtraResource(),
icon,
ignore: getIgnore(),
overwrite: true,
platform: os.platform(),
prune: true,
appCopyright: "Copyright © 2018-present Envox d.o.o.",
appVersion: packageJson.version
};
const appPaths = await packager(options);
fs.copyFileSync("./LICENSE.TXT", appPaths[0] + "/LICENSE.EEZSTUDIO.TXT");
} catch (err) {
console.error(err);
}
process.exit();
})();
示例4: copyFile
export function copyFile(src: string, dest: string, overwrite = true): boolean {
try {
copyFileSync(src, dest, overwrite ? undefined : constants.COPYFILE_EXCL)
} catch (e) {
switch (e.code) {
case "ENOENT":
// 区分是源文件不存在还是目标目录不存在
try {
accessSync(src)
} catch (e2) {
throw e
}
try {
accessSync(dest)
} catch (e3) {
if (e3.code === "ENOENT") {
ensureDirExists(dest)
return copyFile(src, dest, false)
} else {
e = e3
}
}
throw e
case "EEXIST":
return false
default:
throw e
}
}
return true
}
示例5: async
gulp.task('vsix:release:package', async (onError) => {
del.sync(vscodeignorePath);
fs.copyFileSync(onlineVscodeignorePath, vscodeignorePath);
try {
await spawnNode([vscePath, 'package']);
}
finally {
await del(vscodeignorePath);
}
});
示例6: async
gulp.task('vsix:offline:package', async () => {
del.sync(vscodeignorePath);
fs.copyFileSync(offlineVscodeignorePath, vscodeignorePath);
try {
await doPackageOffline();
}
finally {
del(vscodeignorePath);
}
});
示例7: Promise
return new Promise((resolve, reject) => {
this.workingDir = fs.mkdtempSync(path.join(os.tmpdir(), "e2e-app"))
try {
if (fs.statSync(this.path).isDirectory()) {
for (const file of fs.readdirSync(this.path)) {
const src = path.join(this.path, file)
const dst = path.join(this.workingDir, file)
console.debug(`Copy file ${src} => ${dst}`)
fs.copyFileSync(src, dst)
}
} else {
const dst = path.join(this.workingDir, `index${path.extname(this.path)}`)
console.debug(`Copy file ${this.path} => ${dst}`)
fs.copyFileSync(this.path, dst)
}
} catch (err) {
console.warn(err)
reject(new Error("Error copying test app: " + err.toString()))
}
this.child = execa("../../fly", ["server", "-p", this.port.toString(), "--no-watch", this.workingDir], {
env: {
LOG_LEVEL: process.env.LOG_LEVEL,
FLY_ENV: "test",
HOST_ALIASES: JSON.stringify(aliasMap)
}
})
// this.child.on("exit", (code, signal) => {
// console.debug(`[${this.alias}] exit from signal ${signal}`, { code })
// })
this.child.on("error", err => {
console.warn(`[${this.alias}] process error`, { err })
})
this.child.stdout.on("data", chunk => {
console.debug(`[${this.alias}] ${chunk}`)
})
waitOn({ resources: [`tcp:${this.context.hostname}:${this.port}`], timeout: 10000 }).then(resolve, reject)
})
示例8: copy
export function copy(src: string, dest: string, rename?: (dest: string) => string) {
if (!fs.existsSync(src)) {
return;
}
if (fs.statSync(src).isFile()) {
fs.copyFileSync(src, rename ? rename(dest) : dest);
return;
}
const fileNames = fs.readdirSync(src);
mkdir(path.resolve(dest, "dummy"));
fileNames.forEach((fileName) => {
copy(path.resolve(src, fileName), path.resolve(dest, fileName), rename);
});
}
示例9: Promise
const buildGoExecutable = (filename: string): Promise<void> => {
const envGotify = process.env.GOTIFY_EXE;
if (envGotify) {
if (!fs.existsSync(testBuildPath)) {
fs.mkdirSync(testBuildPath);
}
fs.copyFileSync(envGotify, filename);
process.stdout.write(`### Copying ${envGotify} to ${filename}\n`);
return Promise.resolve();
} else {
process.stdout.write(`### Building Gotify ${filename}\n`);
return new Promise((resolve) =>
exec(`go build -o ${filename} ${appDotGo}`, () => resolve())
);
}
};
示例10: copyStatic
async function copyStatic(): Promise<void> {
const files = [
"LICENSE",
"README.md",
"CHANGELOG.md",
"npm-shrinkwrap.json",
"config/config-sample.json",
"config/ext-sample.js",
"public/logo.svg",
"public/favicon.png"
];
for (const file of files) {
fs.copyFileSync(
path.resolve(INPUT_DIR, file),
path.resolve(OUTPUT_DIR, file)
);
}
}