How to use the fs-extra.remove function in fs-extra

To help you get started, we’ve selected a few fs-extra 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 mpmedia / avow-ci / components / runner.js View on Github external
}, function (err) {
    var end = + new Date();
    if (err) {
      self.updateBuildData({ end: end, status: 1, error: { output: err } });
      self.updateProjectStatus(1);
      // Send email (if config'd)
      var mailer = new Mailer({ project: self.project_name, build: self.build });
      // Cleanup
      fsx.remove(self.temp);
    } else {
      // Log end of build
      self.updateBuildData({ end: end, status: 0 });
      self.updateProjectStatus(0);
      // Copy to build folder
      fsx.copy(self.temp, __dirname+'/../builds/'+self.project_name, function (err) {
        if (err) {
          console.log('Error moving completed build of '+self.project_name);
        }
        // Cleanup
        fsx.remove(self.temp);
      });
    }
  });
};
github expo / expo-cli / packages / webpack-pwa-manifest-plugin / src / icons.ts View on Github external
const currentCaches = fs.readdirSync(cacheFolder);

  if (!Array.isArray(currentCaches)) {
    console.warn('Failed to read the icon cache');
    return;
  }
  const deleteCachePromises: Promise[] = [];
  for (const cache of currentCaches) {
    // skip hidden folders
    if (cache.startsWith('.')) {
      continue;
    }

    // delete
    if (!(cache in cacheKeys)) {
      deleteCachePromises.push(fs.remove(path.join(cacheFolder, cache)));
    }
  }

  await Promise.all(deleteCachePromises);
}
github strapi / strapi / packages / strapi-generate / lib / helpers / folder / index.js View on Github external
fs.lstat(rootPath, err => {
    const exists = !(err && err.code === 'ENOENT');
    if (exists && err) {
      return cb.error(err);
    }

    if (exists && !options.force) {
      return cb.alreadyExists('Something else already exists at `' + rootPath + '`.');
    }

    if (exists) {
      fs.remove(rootPath, err => {
        if (err) {
          return cb.error(err);
        }
        _afterwards_();
      });
    } else {
      _afterwards_();
    }

    function _afterwards_() {

      // Don't actually write the directory if this is a dry run.
      if (options.dry) {
        return cb.success();
      }
github seokju-na / geeks-diary / scripts / package.ts View on Github external
path.resolve(DIST_PATH, 'package.json'),
        { overwrite: true },
    );

    console.log('Install dependencies.');
    await spawnAsync('yarn', ['install'], { cwd: DIST_PATH });

    console.log('Rebuild native modules.');
    await spawnAsync('npx', [
        'electron-rebuild',
        '-m',
        'dist/',
    ], { cwd: ROOT_PATH });

    console.log('Optimize nodegit.');
    await remove(path.resolve(DIST_PATH, 'node_modules/nodegit/vendor'));

    console.log('Remove yarn.lock');
    await remove(path.resolve(DIST_PATH, 'yarn.lock'));

    console.log('Prune node modules.');
    await spawnAsync('npm', ['prune', '--production'], { cwd: DIST_PATH });
}
github kyma-project / website / tools / content-loader / src / documentation / copy.js View on Github external
async removeDir(dir) {
    try {
      await fs.remove(dir);
    } catch (err) {
      console.error(err);
    }
  }
github faastjs / faast.js / src / local / local-faast.ts View on Github external
await Promise.all(state.executors.map(e => e.wrapper.stop()));
    await Promise.all(
        state.executors.map(e => new Promise(resolve => e.logStream?.end(resolve)))
    );
    state.executors = [];
    if (state.gcPromise) {
        await state.gcPromise;
    }

    if (options.deleteResources) {
        const { tempDir } = state;
        const pattern = new RegExp(`/faast/${uuidv4Pattern}$`);
        if (tempDir.match(pattern) && (await pathExists(tempDir))) {
            log.info(`Deleting temp dir ${tempDir}`);
            await remove(tempDir);
        }
    }
    log.info(`local cleanup done.`);
}
github shopgate / platform-sdk / lib / actions / ExtensionAction.js View on Github external
async _cleanUp (state, defaultPath) {
    if (state.cloned) await fsEx.remove(state.moved ? state.extensionPath : defaultPath)
  }
github materiahq / materia-server / src / api / controllers / boilerplate.ctrl.ts View on Github external
private _removeBoilerplatePackage(projectName?: string): Promise {
		return fse.remove(path.join(this.app.path, projectName ? projectName : this.app.config.packageJson.name, 'package.json'));
	}
github wireapp / wire-web-packages / packages / license-collector / src / LicenseCollector.ts View on Github external
public async collect(): Promise {
    await this.checkPrerequisites();
    await this.createTempDir();
    await this.clone();
    await this.findRepositories();

    const result = await this.crawl();

    await fs.remove(this.TMP_DIR);

    return this.format(result);
  }
}