await fs.move(imagePath, destFile, { overwrite: true });
await fs.move(`${wd}/${file}`, `${wd}/tar-${file}/hygen.exe`) await execa.command( `cd ${wd}/tar-${file} && zip ../hygen.${plat}.v${v}.zip hygen.exe`, await fs.move(`${wd}/${file}`, `${wd}/tar-${file}/hygen`) await execa.command( `cd ${wd}/tar-${file} && tar -czvf ../hygen.${plat}.v${v}.tar.gz hygen`,
.then(() => fs.move(repoDirPath, testDirPath)) }, Promise.resolve())
const zip = new AdmZip(zipFile); zip.extractAllTo('', true); fs.move(fromDir, directories[dir], function(err) { if (err) { return done(err);
/* Move a file or directory */ router.post('/move', function(req, res) { fs.move(path.join(serverRoot, req.body.f || req.body.d), path.join(serverRoot, req.body.n), function (err) { if (err) { res.send({ res:"error", msg: err }); } else{ res.send({ res: "ok", msg: "Success" }); } }); });
async function renameBlob( article ) { var bpath = blobPath(article.clusterIdx, article.blobIdx) if (article.nameSpace == 'M') { // metadata const data = await fs.readFile ( bpath, 'utf8' ) metadata.push([article.url.toLowerCase(), data]) return fs.unlink( bpath ) } const apath = articlePath( article ) log('renameBlob', article.index, header.articleCount, bpath, '->', apath ) return fs.move( bpath, apath, { clobber: true }) }
async function initDir ( url, path ) { wiki.outPath = path || sanitizeFN( urlconv.parse( url ).hostname ) let done = true if ( command.rmdir ) { const oldDir = wiki.outPath + '$' try { await fs.move( wiki.outPath, oldDir, { overwrite: true }) } catch ( err ) { log( 'initDir', err ) } done = fs.remove( oldDir ) } await fs.mkdirs( wiki.outPath ) return { done } }
/** * Upload file to local uploads directory * * @param {Object} file * @param {String} uploadPath * @param {Function} callback * @return {void} */ function uploadFile(file, uploadPath, callback) { let destPath = path.join(uploadsDir, uploadPath) fs.move(file.path, destPath, { clobber: true }, err => { if (err) { return callback(err) } callback(null, { type : 'local', url : `${ mandi.config.publicUrl }/uploads/${ uploadPath }`, path : uploadPath }) }) }
var start = function (torrentId) { var c = new Client() c.download(torrentId, url, function (hash) { self.client[hash] = c }, function (err, torrent) { delete self.client[torrent.infoHash] if (err) { LogWorker.error(`Fail downloading: ${url}`) } else { c.stop() LogWorker.info(`Moving: ${Path.join(__config.torrent.downloads, torrent.name)} to ${Path.join(__config.directory.path, torrent.name)}`) fs.move(Path.join(__config.torrent.downloads, torrent.name), Path.join(__config.directory.path, torrent.name), function (err) { if (err) { LogWorker.error(err) } else { Directory.list('', function () { Directory.setOwner(torrent.name, user) }) } }) } }) }
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore // See: https://github.com/npm/npm/issues/1862 fs.move( path.join(appPath, 'gitignore'), path.join(appPath, '.gitignore'), [], err => { if (err) { // Append if there's already a `.gitignore` file there if (err.code === 'EEXIST') { const data = fs.readFileSync(path.join(appPath, 'gitignore')); fs.appendFileSync(path.join(appPath, '.gitignore'), data); fs.unlinkSync(path.join(appPath, 'gitignore')); } else { throw err; } } } );
var save = function (file, filename, req, callback) { var realName = util.getFileName(path.extname(filename)); var dPath = util.getRealDynamicPath(req); var saveTo = path.join(os.tmpDir(), realName); file.pipe(fs.createWriteStream(saveTo)); file.on('end', function() { if (config.mode == 'bcs') { var id = setTimeout(function() { callback('timeout'); }, 10000); bcsPutObject(dPath, realName, 'public-read', saveTo, id, callback); } else { var readPath = path.join(config.staticPath, dPath, realName); fse.move(saveTo, readPath, function(err) { if (err) { callback(err); } else { callback(null, dPath + '/' + realName); } }); } }); }
var uploadscrawl = function (req, res) { var realName = util.getFileName('.png'); var saveTo = path.join(os.tmpDir(), realName); //console.log(saveTo); util.base64Decode(req.body.upfile, saveTo, function (err) { var dPath = util.getRealDynamicPath(req); var readPath = path.join(config.staticPath, dPath, realName); var r = { 'url': dPath + '/' + realName, 'original': realName, } if (err) { r.state = 'ERROR'; res.json(r); return; } fse.move(saveTo, readPath, function(err) { if (err) { r.state = 'ERROR'; } else r.state = 'SUCCESS'; res.json(r); }); }); }
async function renameBlob( article ) { var bpath = blobPath(article.clusterIdx, article.blobIdx) if (article.nameSpace == 'M') { // metadata const data = await fs.readFile ( bpath, 'utf8' ) metadata.push([article.url.toLowerCase(), data]) return fs.unlink( bpath ) } const apath = articlePath( article ) log('renameBlob', article.index, header.articleCount, bpath, '->', apath ) return fs.move( bpath, apath, { clobber: true }) }
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore // See: https://github.com/npm/npm/issues/1862 fs.move( path.join(appPath, 'gitignore'), path.join(appPath, '.gitignore'), [], err => { if (err) { // Append if there's already a `.gitignore` file there if (err.code === 'EEXIST') { const data = fs.readFileSync(path.join(appPath, 'gitignore')); fs.appendFileSync(path.join(appPath, '.gitignore'), data); fs.unlinkSync(path.join(appPath, 'gitignore')); } else { throw err; } } } );
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore // See: https://github.com/npm/npm/issues/1862 fs.move( path.join(appPath, 'gitignore'), path.join(appPath, '.gitignore'), [], err => { if (err) { // Append if there's already a `.gitignore` file there if (err.code === 'EEXIST') { const data = fs.readFileSync(path.join(appPath, 'gitignore')); fs.appendFileSync(path.join(appPath, '.gitignore'), data); fs.unlinkSync(path.join(appPath, 'gitignore')); } else { throw err; } } } );