Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name: require(path.join(__dirname, '..', directory, 'package.json')).name,
directory: path.join(__dirname, '..', directory)
}))
for (const { name } of localPackages) {
redefine[name] = `http://${address}:${port}/${safeName(name)}.tgz`
}
let isResolveMonorepo = false
try {
isResolveMonorepo = require('../../../package').name === 'resolve'
} catch (e) {}
if (isResolveMonorepo) {
// eslint-disable-next-line import/no-extraneous-dependencies
const resolvePackagesNames = require('create-resolve-app').resolvePackages
// 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 => ({
// 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'))