Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function ncp(source: FilePath, destination: FilePath) {
await _ncp(inputFS, source, outputFS, destination);
}
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;
}
}