How to use rimraf

Comprehensive rimraf code examples:

How to use rimraf.default:

270
271
272
273
274
275
276
277
278
279
 * throws if the revision has not been downloaded.
 */
async remove(revision) {
    const folderPath = this._getFolderPath(revision);
    assert_js_1.assert(await existsAsync(folderPath), `Failed to remove: revision ${revision} is not downloaded`);
    await new Promise((fulfill) => rimraf_1.default(folderPath, fulfill));
}
/**
 * @param revision - The revision to get info for.
 * @returns The revision info for the given revision.

How to use rimraf.native:

1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
    });
},

async rm(f, option = {}) {
    let ok = true;
    await rimraf.native(f, option).catch(function(err) {
        console.error(err);
        ok = false;
    });
    return ok;

How to use rimraf.rimrafSync:

3
4
5
6
7
8
9
10
11
12
13
const postcss = require('esbuild-postcss-plugin');
// const stylePlugin = require('esbuild-style-plugin');
const { rimraf, rimrafSync, native, nativeSync } = require('rimraf');


(async function () {
  await rimrafSync("./dist");
  await esbuild.build({
    entryPoints: ['src/browser.ts'],
    bundle: true,
    minify: true,

How to use rimraf.rimraf:

711
712
713
714
715
716
717
718
719
720
721
function cleanBuildDir() {
  // Sanity check.
  if (BUILD_DIR === '.' || BUILD_DIR === '/') {
    return Promise.reject(`Refusing to rm -rf ${BUILD_DIR}`);
  }
  return rimraf(BUILD_DIR);
}


/**
 * Runs clang format on all files in the core directory.

How to use rimraf.nativeSync:

8
9
10
11
12
13
14
15
16
17
18
// utils
const cleanSnapshotsDir = (options) => {
    const snapshotsDir = options.snapshotsDir;
    if (fs.existsSync(snapshotsDir)) {
        console.log(`${EC.cyan('[clean]')} remove chromium snapshots dir: ${EC.magenta(snapshotsDir)} ...`);
        rimraf.nativeSync(snapshotsDir);
    }
};


const cleanStatsFile = (options) => {

How to use rimraf.sync:

43
44
45
46
47
48
49
50
51
52
  await promisified(server.port);
  console.log(`Server listening on port ${server.port}!`);
});

beforeEach(() => {
  rimraf.sync(server.repository);
});

after(() => {
  rimraf.sync(server.repository);