How to use the rmSync function from fs-extra

Find comprehensive JavaScript fs-extra.rmSync code examples handpicked from public code repositorys.

362
363
364
365
366
367
368
369
370
371
let pluginPath = path.join(backendDir, "tmp", pluginDirName);

if(!fs.existsSync(pluginPath)){
    fs.mkdirSync(pluginPath, {recursive:true});
}else{
    fs.rmSync(pluginPath, {recursive:true});
}

const childProcess = require("child_process");
childProcess.exec("git clone https://github.com/GreySole/Spooder-Sample-Plugin "+pluginPath,{
fork icon3
star icon30
watch icon0

+ 17 other calls in file

653
654
655
656
657
658
659
660
661
662
} catch (err) {
  mainWindow.send('add-app-progress', -1, newApp.id);
  mainWindow.setProgressBar(-1);
  try {
    if (fs.existsSync(appDirTmp)) {
      fs.rmSync(appDirTmp, { recursive: true });
    }
  } catch (errRm) {
    log.error(`Problems removing temporary app directory: ${appDirTmp}. Error message: ${errRm.message}.`);
  }
fork icon1
star icon7
watch icon4

+ 5 other calls in file

42
43
44
45
46
47
48
49
50
// try to extract the plugin
const {resolved} = await extract(pkg.raw, tmp);
Plugin.debug('extracted plugin %o to %o from %o', _id, tmp, resolved);

// if we get this far then we can safely move the plugin to dest
fs.rmSync(dest, {recursive: true, force: true});
fs.mkdirSync(dest, {recursive: true});
fs.copySync(tmp, dest);
Plugin.debug('moved plugin from %o to %o', tmp, dest);
fork icon0
star icon1
watch icon0

+ 9 other calls in file

390
391
392
393
394
395
396
397
398
399
    for (let file of files) {
        if (file === '.' || file === '..' || file === 'media') {
            continue;
        }

        fs.rmSync(path.join(this.outputDir, file), { recursive: true });
    }
} else {
    fs.mkdirSync(this.outputDir);
}
fork icon341
star icon0
watch icon79

+ 4 other calls in file

10
11
12
13
14
15
16
17
18
19
20
21
    removeDir(path.join(pages, item));
  });
}


function removeDir(dir) {
  fse.rmSync(dir, { recursive: true, force: true });
}


function translateDir(directory = docs) {
  fs.readdirSync(directory).forEach((dir) => {
fork icon0
star icon5
watch icon1

+ 2 other calls in file

232
233
234
235
236
237
238
239
240
241
242
 */
function deleteElectronBinaries() {
    const preBuildsFolder = path.join(__dirname, 'node_modules', 'zeromqold', 'prebuilds');
    glob.sync('**/electron.napi.*.node', { sync: true, cwd: preBuildsFolder }).forEach((file) => {
        console.log(`Deleting ${file}`);
        fs.rmSync(path.join(preBuildsFolder, file), { force: true });
    });
}


async function deleteZMQBuildFolder() {
fork icon0
star icon4
watch icon1

+ 21 other calls in file

59
60
61
62
63
64
65
66
67
68
const rows = db.prepare(selectQ).all();
for (const row of rows) {
    // Remove temporary uploads
    const tmpPartPaths = `${PART_PREFIX}${row.id}`;
    console.log(`Removing ${tmpPartPaths}`);
    fs.rmSync(tmpPartPaths, {recursive: true, force: true});
    // Remove cached artifacts if any
    const cacheFile = path.join(CACHE_PATH, row.id.toString());
    console.log(`Removing ${cacheFile}`);
    fs.rmSync(cacheFile, {recurse: true, force: true});
fork icon6
star icon30
watch icon1

+ 5 other calls in file

495
496
497
498
499
500
501
502
503
504
505
}


function removeTmpDir() {
    try {
        if (tmpDir !== null) {
            fs.rmSync(tmpDir, { recursive: true });
            tmpDir = null;
        }
    } catch(e) {
        console.error(`Failed to remove temporary directory "${tmpDir}". Please manually remove it.`);
fork icon0
star icon0
watch icon1

+ 14 other calls in file

59
60
61
62
63
64
65
66
67

logger.info(`Created lockfile ${lockFilePath}`);

const onExitHandler = () => {
   if (fs.existsSync(lockFilePath)) {
      fs.rmSync(lockFilePath, { force: true });
      logger.info(`Removed lockfile ${lockFilePath}`);
   }
};
fork icon0
star icon0
watch icon0

+ 3 other calls in file

function icon

fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)