How to use the fs-extra2.emptyDirSync function in fs-extra2

To help you get started, we’ve selected a few fs-extra2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github avwo / whistle / bin / plugin.js View on Github external
function install(cmd, name, argv) {
  argv = argv.slice();
  var result = getInstallDir(argv);
  argv = result.argv;
  var installPath = getInstallPath(getTempName(name), result.dir);
  fse.ensureDirSync(installPath);
  fse.emptyDirSync(installPath);
  fs.writeFileSync(path.join(installPath, 'package.json'), PACKAGE_JSON);
  fs.writeFileSync(path.join(installPath, 'LICENSE'), LICENSE);
  fs.writeFileSync(path.join(installPath, 'README.md'), RESP_URL);
  argv.unshift('install', name);
  cp.spawn(cmd, argv, {
    stdio: 'inherit',
    cwd: installPath
  }).on('exit', function(code) {
    if (code) {
      removeDir(installPath);
    } else {
      var realPath = getInstallPath(name, result.dir);
      removeDir(realPath);
      try {
        fs.renameSync(installPath, realPath);
      } catch (e) {

fs-extra2

fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.

MIT
Latest version published 7 months ago

Package Health Score

64 / 100
Full package analysis