How to use the @parcel/fs.ncp 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 / test-utils / src / utils.js View on Github external
export async function ncp(source: FilePath, destination: FilePath) {
  await _ncp(inputFS, source, outputFS, destination);
}
github parcel-bundler / parcel / packages / core / package-manager / src / MockPackageInstaller.js View on Github external
async installPackage(
    packageName: string,
    fs: FileSystem,
    packagePath: FilePath,
  ) {
    let pkg = this.packages.get(packageName);
    if (!pkg) {
      throw new Error('Unknown package ' + packageName);
    }

    let dest = path.join(
      path.dirname(packagePath),
      'node_modules',
      packageName,
    );
    await ncp(pkg.fs, pkg.packagePath, fs, dest);

    let packageJSON = JSON.parse(
      await fs.readFile(path.join(dest, 'package.json'), 'utf8'),
    );
    let deps = packageJSON.dependencies || {};
    for (let dep in deps) {
      await this.installPackage(dep, fs, packagePath);
    }

    return packageJSON.version;
  }
}