How to use the @parcel/fs.rimraf function in @parcel/fs

To help you get started, we’ve selected a few @parcel/fs 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 parcel-bundler / parcel / packages / core / parcel-bundler / src / assets / KotlinAsset.js View on Github external
let source = await fs.readFile(filename, 'utf8');
    let sourceMap;
    if (this.options.sourceMaps) {
      sourceMap = await fs.readFile(filename + '.map', 'utf8');

      sourceMap = JSON.parse(sourceMap);
      sourceMap.sources = [this.relativeName];
      sourceMap.sourcesContent = [this.contents];

      // remove source map url
      source = source.substring(0, source.lastIndexOf('//# sourceMappingURL'));
    }

    // delete temp directory
    await fs.rimraf(dir);

    return [
      {
        type: 'js',
        value: source,
        sourceMap,
      },
    ];
  }
}