Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 4. Remove all resolve packages in node_modules
for (const { directory } of localPackages) {
for (const name of resolvePackagesNames) {
const resolvePackagePath = path.normalize(
path.join(directory, 'node_modules', name)
)
if (fs.existsSync(resolvePackagePath)) {
removeExtra(resolvePackagePath)
}
}
}
resolvePackages.push(
...resolvePackagesNames.map(packageName => ({
name: packageName,
directory: path.dirname(
require.resolve(path.join(packageName, 'package.json'))
)
}))
)
for (const { name } of resolvePackages) {
redefine[name] = `http://${address}:${port}/${safeName(name)}.tgz`
}
}
// 5. Backup package.json-s and setup rollback
const backup = {}
for (const { directory } of [...localPackages, ...resolvePackages]) {
backup[directory] = fs.readFileSync(path.join(directory, 'package.json'))