Skip to content

Commit

Permalink
refactor: dependency installer
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Mar 20, 2023
1 parent 74974b5 commit 4312909
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions scopes/dependencies/dependency-resolver/dependency-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,6 @@ export class DependencyInstaller {
resolveVersionsFromDependenciesOnly: options.resolveVersionsFromDependenciesOnly,
referenceLocalPackages: packageManagerOptions.rootComponentsForCapsules,
});
if (options.linkedDependencies) {
const directDeps = new Set<string>();
Object.values(manifests).forEach((manifest) => {
for (const depName of Object.keys({ ...manifest.dependencies, ...manifest.devDependencies })) {
directDeps.add(depName);
}
});
for (const manifest of Object.values(manifests)) {
if (manifest.name && directDeps.has(manifest.name)) {
delete options.linkedDependencies[finalRootDir][manifest.name];
}
}
Object.entries(options.linkedDependencies).forEach(([dir, linkedDeps]) => {
if (!manifests[dir]) {
manifests[dir] = {};
}
manifests[dir].dependencies = Object.assign({}, manifests[dir].dependencies, linkedDeps);
});
}
return this.installComponents(
finalRootDir,
manifests,
Expand Down Expand Up @@ -158,6 +139,27 @@ export class DependencyInstaller {
if (!finalRootDir) {
throw new RootDirNotDefined();
}
if (options.linkedDependencies) {
const directDeps = new Set<string>();
Object.values(manifests).forEach((manifest) => {
for (const depName of Object.keys({ ...manifest.dependencies, ...manifest.devDependencies })) {
directDeps.add(depName);
}
});
if (options.linkedDependencies[finalRootDir]) {
for (const manifest of Object.values(manifests)) {
if (manifest.name && directDeps.has(manifest.name)) {
delete options.linkedDependencies[finalRootDir][manifest.name];
}
}
}
Object.entries(options.linkedDependencies).forEach(([dir, linkedDeps]) => {
if (!manifests[dir]) {
manifests[dir] = {};
}
manifests[dir].dependencies = Object.assign({}, manifests[dir].dependencies, linkedDeps);
});
}
// Make sure to take other default if passed options with only one option
const calculatedPmOpts = {
...DEFAULT_PM_INSTALL_OPTIONS,
Expand Down

0 comments on commit 4312909

Please sign in to comment.