How to use the remove function from fs-extra
Find comprehensive JavaScript fs-extra.remove code examples handpicked from public code repositorys.
260 261 262 263 264 265 266 267 268
errorData.indexOf('Test logger - debug').should.equal(-1); }); after(async () => { // Remove tmp dir await fs.remove(tmpDir); }); });
+ 13 other calls in file
62 63 64 65 66 67 68 69 70 71
log.trace(`[uibuilder:uiblib:instanceClose] Deleting instance folder. URL: ${node.url}`) // Remove the flag in case someone recreates the same url! delete uib.deleteOnDelete[node.url] fs.remove(path.join(uib.rootFolder, node.url)) .catch(err => { log.error(`[uibuilder:uiblib:processClose] Deleting instance folder failed. URL=${node.url}, Error: ${err.message}`) }) }
+ 12 other calls in file
GitHub: alphagov/govuk-prototype-kit
236 237 238 239 240 241 242 243 244 245
await npmInstall(installDirectory, [kitDependency, 'govuk-frontend', '@govuk-prototype-kit/common-templates']) if ((argv.options.version || argv.options.v) === 'local-symlink') { const dependencyInstallLocation = path.join(installDirectory, 'node_modules', kitProjectName) await fs.remove(dependencyInstallLocation) await fs.ensureSymlink(kitDependency, dependencyInstallLocation) } let runningWithinCreateScriptFlag = '--running-within-create-script'
+ 14 other calls in file
231 232 233 234 235 236 237 238 239
或者使用 `async/await`: ```js async function removeFolder(folder) { try { await fs.remove(folder) }//done catch (err) {console.error(err) } }
+ 9 other calls in file
233 234 235 236 237 238 239 240 241 242
``` or with `async/await`: ``` async function removeFolder(folder) { try { await fs.remove(folder) //done } catch (err) { console.error(err) }} ``` ``` const folder = '/Users/flavio'removeFolder(folder)
+ 13 other calls in file
987 988 989 990 991 992 993 994 995 996
// 尚未获得管理权,中断处理 if (!remoteTokenInfo.value || remoteTokenInfo.value !== token) return callback(); // 已经获得管理权,删除 Token return fs.remove(remoteTokenInfo.path, asyncCallback); }, // 上传 function(asyncCallback) { var pushContent = {
GitHub: mgol/check-dependencies
631 632 633 634 635 636 637 638 639 640
fs.existsSync(`${fixtureCopyDir}/${depsDirName}/jquery/dist`), false, ); Promise.all([]) .then(() => fs.remove(fixtureCopyDir)) .then(() => fs.copy(fixtureDir, fixtureCopyDir)) .then(() => { checkDeps( {
+ 27 other calls in file
238 239 240 241 242 243 244 245 246 247
или с `async/await`: ```js async function removeFolder(folder) { try { await fs.remove(folder); // done } catch (err) { console.error(err); }
+ 11 other calls in file
GitHub: MarkBind/markbind
856 857 858 859 860 861 862 863 864 865
const filePathArray = Array.isArray(filePaths) ? filePaths : [filePaths]; const uniquePaths = _.uniq(filePathArray); const fileRelativePaths = uniquePaths.map(filePath => path.relative(this.rootPath, filePath)); const filesToRemove = fileRelativePaths.map( fileRelativePath => path.join(this.outputPath, fileRelativePath)); const removeFiles = filesToRemove.map(asset => fs.remove(asset)); if (removeFiles.length !== 0) { await Promise.all(removeFiles); logger.debug('Assets removed'); }
+ 11 other calls in file
GitHub: MarkBind/markbind
161 162 163 164 165 166 167 168 169 170
*/ static async rejectHandler(error, removeFolders) { logger.warn(error); try { await Promise.all(removeFolders.map(folder => fs.remove(folder))); } catch (err) { logger.error(`Failed to remove generated files after error!\n${err.message}`); } }
+ 41 other calls in file
GitHub: data-fair/data-fair
492 493 494 495 496 497 498 499 500 501
const job = new CronJob(config.exportRestDatasets.cron, () => {}) patch.exports.restToCSV.nextExport = job.nextDates().toISOString() } else { delete patch.exports.restToCSV.nextExport if (await fs.pathExists(datasetUtils.exportedFilePath(req.dataset, '.csv'))) { await fs.remove(datasetUtils.exportedFilePath(req.dataset, '.csv')) } } patch.exports.restToCSV.lastExport = req.dataset?.exports?.restToCSV?.lastExport }
+ 11 other calls in file
33 34 35 36 37 38 39 40 41 42
} }; var userDir = path.join(__dirname,".testUserHome"); var testFlow = [{"type":"tab","id":"d8be2a6d.2741d8","label":"Sheet 1"}]; beforeEach(function(done) { fs.remove(userDir,function(err) { fs.mkdir(userDir,done); }); }); afterEach(function(done) {
GitHub: davidmerfield/Blot
207 208 209 210 211 212 213 214 215 216
// We encountered some file system error moving the temp // file to its final location in the cache directory. // Remove the temporary output and go on with our lives. if (err) debug(err); fs.remove(tmp_path, function (err) { // Nothing else we can really do here if (err) debug(err); }); });
+ 7 other calls in file
565 566 567 568 569 570 571 572 573 574
}) try { await fs.remove(getNodeFile()) await fs.remove(getNodeChainDbFolder()) await fs.remove(getNodeIpfsDir()) sendMainWindowMsg(NODE_EVENT, 'troubleshooting-reset-node') } catch (e) { logger.error('error deleting idenachain.db', e.toString())
+ 20 other calls in file
212 213 214 215 216 217 218 219 220 221
if (url) { const urlArr = [] urlArr.push(url) const signUrl = await fileService.getSignUrl(urlArr, 0) resolve(signUrl) fse.remove(`${targetPath}.tar.gz`) fse.remove(sourcePath) } } catch (err) { reject(new Error(`打包压缩并上传包过程失败: ${err}`))
+ 5 other calls in file
GitHub: data-fair/data-fair
891 892 893 894 895 896 897 898 899 900
{ $set: patch, $unset: { draft: '' } }, { returnDocument: 'after' } )).value if (dataset.prod.originalFile) await fs.remove(exports.originalFilePath(dataset.prod)) if (dataset.prod.file) { await fs.remove(exports.filePath(dataset.prod)) await fs.remove(exports.fullFilePath(dataset.prod)) webhooks.trigger(db, 'dataset', patchedDataset, { type: 'data-updated' }) if (req) {
+ 55 other calls in file
GitHub: athombv/node-homey
809 810 811 812 813 814 815 816 817 818
if (App.hasHomeyCompose({ appPath: this.path })) { await HomeyCompose.build({ appPath: this.path }); } // Clear the .homeybuild/ folder await fse.remove(this._homeyBuildPath).catch(async err => { // It helps to wait a bit when ENOTEMPTY is thrown. if (err.code === 'ENOTEMPTY') { await new Promise(resolve => setTimeout(resolve, 2000)); return fse.remove(this._homeyBuildPath);
+ 3 other calls in file
GitHub: adobe/asset-compute-sdk
327 328 329 330 331 332 333 334 335 336
this.timers.postProcessing.stop(); console.log(`post-processing ${rendition.name} finished successfully in ${this.timers.postProcessing} seconds`); if (process.env.WORKER_TEST_MODE) { // test-worker finds renditions using a rendition* glob by default, so we must ensure there is only one left await fse.remove(rendition.path); } // point to proper rendition once postprocessing done this.renditions[rendition.index] = newRendition;
+ 3 other calls in file
4679 4680 4681 4682 4683 4684 4685 4686 4687 4688
VlocityUtils.verbose('Deploying Metadata', deploymentOptions.sourcepath); try { if (jobInfo.deployAllSalesforce) { if (fs.existsSync(tempSfdxFolder)) { await fs.remove(tempSfdxFolder); } /* Move Profiles folder to temp location to make them deploy separately */ if (fs.existsSync(profilesFolder)) {
+ 7 other calls in file
GitHub: utsuboco/create-r3f-app
153 154 155 156 157 158 159 160 161 162
await fs.writeFile(sysPath.join(root, `./src/index.d.ts`), shader); await fs.writeFile(sysPath.join(root, "tsconfig.json"), tsconfig, { spaces: 2, }); await fs.remove(sysPath.join(root, "jsconfig.json")); await fs.remove(sysPath.join(root, "jsconfig.server.json")); const packageJson = await fs.readJSON(sysPath.join(root, "package.json")); const { scripts, ...otherConfigs } = packageJson; scripts.prettier = `npx prettier --list-different \"./src/**/*.{ts,tsx,md}\" \"./app/**/*.{ts,tsx,md}\""`;
+ 13 other calls in file
fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)