function copyBundle() { const srcPath = path.resolve(buildPath, "esm.js") return fs.existsSync(srcPath) ? fs.copy(srcPath, loaderPath) : Promise.resolve() }
async function copyToDist(distDir) { await copyDir(clipperDir, 'popup/build', distDir); await copyDir(clipperDir, 'content_scripts', distDir); await copyDir(clipperDir, 'icons', distDir); await fs.copy(`${clipperDir}/background.js`, `${distDir}/background.js`); await fs.copy(`${clipperDir}/manifest.json`, `${distDir}/manifest.json`); await fs.remove(`${distDir}/popup/build/manifest.json`); }
async function copyDir(baseSourceDir, sourcePath, baseDestDir) { await fs.mkdirp(`${baseDestDir}/${sourcePath}`); await fs.copy(`${baseSourceDir}/${sourcePath}`, `${baseDestDir}/${sourcePath}`); }
/** * @description Replace the local sqlite database with a backup. * @param {string} backupFilePath - The path of the backup. * @example * restoreBackup('/backup.db'); */ async function restoreBackup(backupFilePath) { logger.info(`Restoring back up ${backupFilePath}`); // ensure that the file exists const exists = await fse.pathExists(backupFilePath); if (!exists) { throw new NotFoundError('BACKUP_NOT_FOUND'); } // shutting down the DB await this.sequelize.close(); // copy the backupFile to the new DB await fse.copy(backupFilePath, this.config.storage); // done! logger.info(`Backup restored. Need reboot now.`); }
fse.copy(templatePath, targetPath, function(err){ if(err){ logger.error(err); return } this._replaceProjectName(projName, targetPath, registry); }.bind(this));
fs.copy(SRC, DIST) .then(() => { console.log('Success') }) .catch(err => { console.error(err) })
// copy topojson files from sane-topojson to dist/ fs.copy(constants.pathToTopojsonSrc, constants.pathToTopojsonDist, { clobber: true }, function(err) { if(err) throw err; } );
// 拷贝模板文件 fs.copy(src, dest).then(() => { // 根据选项写入文件 appendFiles(); // 执行自动安装依赖 spawnCmd(dest); });
/** * @summary Copies a file to the build directory * @param {String} file File path * @returns {Promise<undefined>} Nothing */ async function copyFile(file) { const buildPath = path.resolve(process.cwd(), "dist", path.basename(file)); await fse.copy(file, buildPath); console.log(`Copied ${file} to ${buildPath}`); }
let initDiffVbot = async (threshold) => { let imgdir = `${testPath}/tmp/compare_imgs` vbot = new VBot({verbose: false}) fs.removeSync(imgdir) // await fs.copy(`${testPath}/fixtures/compare_imgs/same`, `${testPath}/tmp/compare_imgs/view1/base`) await fs.copy(`${testPath}/fixtures/compare_imgs/diff/2_scrollTo-.box.png`, `${testPath}/tmp/compare_imgs/view1/base/2_scroll-.box.png`) vbot.start(playbook, {imgdir: imgdir, mismatchThreshold: threshold}) }
(async function main() { try { await fs.remove(targetPath); await fs.copy(buildPath, targetPath); } catch (err) { console.error(err); } })();
// Async/Await: async function copyFiles() { try { await fs.copy('my-file', 'my-file-2'); console.log('success!'); } catch (err) { console.error(err); } }
/** * @summary Copies a file to the build directory * @param {String} file File path * @returns {Promise<undefined>} Nothing */ async function copyFile(file) { const buildPath = path.resolve(process.cwd(), "dist", path.basename(file)); await fse.copy(file, buildPath); console.log(`Copied ${file} to ${buildPath}`); }