本文整理汇总了TypeScript中fs.copyFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript copyFile函数的具体用法?TypeScript copyFile怎么用?TypeScript copyFile使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copyFile函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
vscode.workspace.getConfiguration().update("print.colourScheme", newValue, vscode.ConfigurationTarget.Global).then(() => {
if (path !== stylePath) {
let newCachePath = `${stylePath}/${newValue}.css`;
fs.copyFile(p, newCachePath, err => {
vscode.window.showErrorMessage(err.message);
});
}
}, (err) => {
示例2: Promise
return new Promise((resolve, reject) => {
fs.copyFile(`${cwd}/${file}`, `${distDir}/${file}`, err => {
if (err) {
reject(err);
return;
}
resolve();
});
});
示例3: afterEach
afterEach(async function () {
if (this.currentTest.state && this.currentTest.state === "failed") {
let png = await driver.logScreenshot(this.currentTest.title);
fs.copyFile(png, "./mochawesome-report/" + this.currentTest.title + ".png", (err) => {
if (err) throw err;
console.log("Image saved");
});
addContext(this, "./" + this.currentTest.title + ".png");
}
});
示例4: afterEach
afterEach(async function () {
if (this.currentTest.state && this.currentTest.state === "failed") {
let png = await driver.logScreenshot(this.currentTest.title);
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
if (err) {
throw err;
}
console.log('Screenshot saved.');
});
addContext(this, './' + this.currentTest.title + '.png');
}
});
示例5: cf
s = fs.realpathSync.native('/path/to/folder', undefined);
s = fs.realpathSync.native('/path/to/folder', 'utf8');
b = fs.realpathSync.native('/path/to/folder', 'buffer');
const v3 = fs.realpathSync.native('/path/to/folder', s);
typeof v3 === "string" ? s = v3 : b = v3;
s = fs.realpathSync.native('/path/to/folder', {});
s = fs.realpathSync.native('/path/to/folder', { encoding: undefined });
s = fs.realpathSync.native('/path/to/folder', { encoding: 'utf8' });
b = fs.realpathSync.native('/path/to/folder', { encoding: 'buffer' });
const v4 = fs.realpathSync.native('/path/to/folder', { encoding: s });
typeof v4 === "string" ? s = v4 : b = v4;
}
{
fs.copyFile('/path/to/src', '/path/to/dest', (err) => console.error(err));
fs.copyFile('/path/to/src', '/path/to/dest', fs.constants.COPYFILE_EXCL, (err) => console.error(err));
fs.copyFile('/path/to/src', '/path/to/dest', fs.constants.COPYFILE_FICLONE, (err) => console.error(err));
fs.copyFile('/path/to/src', '/path/to/dest', fs.constants.COPYFILE_FICLONE_FORCE, (err) => console.error(err));
fs.copyFileSync('/path/to/src', '/path/to/dest', fs.constants.COPYFILE_EXCL);
fs.copyFileSync('/path/to/src', '/path/to/dest', fs.constants.COPYFILE_FICLONE);
fs.copyFileSync('/path/to/src', '/path/to/dest', fs.constants.COPYFILE_FICLONE_FORCE);
const cf = util.promisify(fs.copyFile);
cf('/path/to/src', '/path/to/dest', fs.constants.COPYFILE_EXCL).then(console.log);
}
{
fs.mkdir('some/test/path', {
recursive: true,
示例6: Promise
return new Promise((resolve, reject) => {
fs.copyFile(input, output, options, (error, ...args: any[]) => {
error ? reject(error) : resolve.apply(null, args)
})
})