How to use the emptyDir function from fs-extra
Find comprehensive JavaScript fs-extra.emptyDir code examples handpicked from public code repositorys.
GitHub: cnpm/npminstall
419 420 421 422 423 424 425 426 427 428
options.cache[key] = { done: false, }; if (!(await exports.isInstallDone(targetdir))) { await fse.emptyDir(targetdir); await fse.copy(src, targetdir); await exports.setInstallDone(targetdir); result.exists = false; }
64
475
17
1339 1340 1341 1342 1343 1344 1345 1346 1347
'--word') // Clear the previous output folder if it exists, // or create the output directory first if it doesn't. if (pathExists(outputLocation)) { await fs.emptyDir(outputLocation) } else { await fs.mkdir(outputLocation, { recursive: true }) }
39
105
0
+ 5 other calls in file
GitHub: heiseonline/embetty
93 94 95 96 97 98 99 100 101 102 103
} const main = async () => { const url = await launchServer() const baseDir = path.join(__dirname, '.gh-pages') await fs.emptyDir(baseDir) await Promise.all([ download(baseDir, `${url}/index.html`), download(baseDir, `${url}/tweet.html`), download(baseDir, `${url}/video.html`),
31
938
25
+ 10 other calls in file
385 386 387 388 389 390 391 392 393 394
const dir = path.join(datasetUtils.attachmentsDir(req.dataset), lineId) if (req.file) { // An attachment was uploaded await fs.ensureDir(dir) await fs.emptyDir(dir) await fs.rename(req.file.path, path.join(dir, req.file.originalname)) const relativePath = path.join(lineId, req.file.originalname) const pathField = req.dataset.schema.find(f => f['x-refersTo'] === 'http://schema.org/DigitalDocument') if (!pathField) {
6
26
4
+ 3 other calls in file
GitHub: LibreTexts/Libretext
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613
}).then(); } } await fs.emptyDir(`./PDF/Letter/libretexts/${zipFilename}`); await fs.emptyDir(`./PDF/Letter/Finished/${zipFilename}`); if (hasCoverpage) await fs.ensureDir(`./PDF/Letter/Finished/${zipFilename}/Publication`); await fs.emptyDir(`./PDF/Letter/order/${thinName}/`);
8
11
6
+ 29 other calls in file
GitHub: athombv/node-homey
609 610 611 612 613 614 615 616 617 618
const userdataDir = path.join(Settings.getSettingsDirectory(), 'apps-userdata', manifest.id); if (homey.platform === 'local') { await fse.ensureDir(userdataDir); if (clean === true) { await fse.emptyDir(userdataDir); } fse.watch(userdataDir, (_, filename) => { if (userdataDirWarned === false) {
4
5
4
+ 3 other calls in file
145 146 147 148 149 150 151 152 153 154 155
* and extract svg files, then write it to icons directory. */ // eslint-disable-next-line max-lines-per-function const buildIcons = async function () { // Empty directory first await fse.emptyDir(path.resolve(__dirname, '../icons')); await fse.emptyDir(path.resolve(__dirname, '../csv')); // Hold all icons info in this array const fullContent = [];
2
21
1
+ 5 other calls in file
41 42 43 44 45 46 47 48 49 50
pathExistsAsync = fname => fse.pathExists(getAbsPath(fname)) copyAsync = (src, dest) => fse.copy(src,dest) ensureDirAsync = dirPath => fse.ensureDir(dirPath) moveAsync = (srcPath,destPath) => fse.move(srcPath,destPath) removeAsync = dirPath => fse.remove(dirPath) emptyDirAsync = dirPath => fse.emptyDir(dirPath) getAllFiles = async (dir) => { const useDir = getAbsPath(dir) const filenamesArr = await readdirAsync(useDir)
1
3
3
130 131 132 133 134 135 136 137 138
gulp.task('build-pages', async function () { await killableSpawn('hexo', ['generate'], { cwd: testCwd }); }); gulp.task('copy-pages', async function () { if (fs.existsSync(deployDest) && fs.existsSync(testPublic)) { await fs.emptyDir(deployDest); await fs.copy(testPublic, deployDest, { overwrite: true }); } });
1
2
1
121 122 123 124 125 126 127 128 129
}); gulp.task('copy-pages', async function () { const dest = path.join(__dirname, '../../site/.deploy_git/docs/hexo-shortcodes'); const src = path.join(__dirname, 'test/public'); if (fs.existsSync(dest) && fs.existsSync(src)) { await fs.emptyDir(dest); await fs.copy(src, dest, { overwrite: true }); } });
1
2
1
+ 43 other calls in file
46 47 48 49 50 51 52 53 54 55
flowEnabler.subscribe(RED); // one time step to re create flow file on start of the service createNewCombinedFlow({}); logFolder = path.join(userDir, "logs"); //Clears all old logs in directory fs.emptyDir(logFolder); //app clossing event trigger multiple times this is used to trigger remove flow only once. let appClosing = false; subscribeAppInstall.on("response", (response) => { if (response.payload.details) {
0
2
0
GitHub: Kunedawg/kev-bot
165 166 167 168 169 170 171 172 173 174
}); } // Clean up the temporary data try { await fs.emptyDir(tempDataPath); } catch (err) { return reject({ userMess: "File uploaded, but cleanup failed. Definitely let Kevin know!", err: err,
1
1
2
+ 11 other calls in file
GitHub: unbywyd/ungic
196 197 198 199 200 201 202 203 204 205
} this.setConfig(response); } if (options.createMode) { await fse.emptyDir(options.root); } options.app = this; let prj = new ungicProject(this.config, options); try {
0
2
1
+ 6 other calls in file
59 60 61 62 63 64 65 66 67 68
.map(entry => entry.substr(this.workspace.length)); core.debug(`Found the following matching files: \n${patternMatches.join("\n")}`); sources.push(...patternMatches); } core.debug("Copying all files and folders to a common directory..."); await fs_extra_1.emptyDir(rootFolder); for (const source of sources) { const basename = path_1.default.basename(source); const target = path_1.default.join(rootFolder, basename); core.debug(`Copying ${source} to ${target}`);
0
0
0
+ 18 other calls in file
288 289 290 291 292 293 294 295 296 297
this.WasFilter = filterScripts(this.options.webAccessibleScripts) } async writeBuild({ port, manifest, htmlFiles }) { this.hmrServer = this.getHmrServer(port) // copies the content of public ditrectory await fs.emptyDir(this.outDir) const publicDir = path.resolve( process.cwd(), this.viteConfig.root, this.viteConfig.publicDir,
0
0
1
+ 24 other calls in file
136 137 138 139 140 141 142 143 144 145
server.log(["debug"], `loaded release tarball for ${pack.name}`); timingInfo.releaseTarballLoaded = Date.now() - loadPackageStartTime; // clear the directory first await fs.emptyDir(savePath); await new Promise((resolve, reject) => { let stream = response.body .pipe(zlib.createGunzip())
0
0
16
+ 10 other calls in file
GitHub: Pauloo200/progect
40 41 42 43 44 45 46 47 48 49
await canvasx('lime', 0, texto) res.type('jpeg') res.sendFile(__path + '/src/frames/frame0.png') //await fs.unlink(__path + '/src/ttp.gif', () => { //await fs.unlink(__path + '/src/attp.webp', () => {}); //await fs.emptyDir(__path + '/src/frames', () => {}); } catch(err) { console.log(err) res.status(500).send({ status: 500, info: 'ops, aconteceu um erro no servidor interno, contate o admin pelo Whatsapp wa.me/5516993025827', resultado: 'error'
0
0
1
+ 5 other calls in file
GitHub: byu-oit/web-cdn
45 46 47 48 49 50 51 52 53 54
log.warn("This is a dry run!") } log.info(`Using ${workDir} as scratch directory`); // await fs.emptyDir(workDir); await fs.ensureDir(workDir); let sourceDir = path.join(workDir, 'sources'); let assembledDir = path.join(workDir, 'assembled');
0
0
4
+ 2 other calls in file
GitHub: ReturnTypeVoid/dae
263 264 265 266 267 268 269 270 271 272
await fs.remove(linkDir); } else { console.log(chalk.green(`Copying build to ${chalk.blueBright(linkDir)}`)); await fs.emptyDir(linkDir); await fs.copy('dist', linkDir); } return cb(); } catch (err) {
0
0
1
10 11 12 13 14 15 16 17 18 19
// Register some custom handlebar helpers that are used in the template registerHelpers(handlebars) // Ensure directories await fs.ensureDir(output) // Try to remove existing files and create folder if it does not exist await fs.emptyDir(output) .then(() => console.log('Output directory cleared')) .catch(err => console.error("Could not empty output directory with error: ", err)); // Global settings
0
0
2
+ 7 other calls in file
fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)