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