-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: try to fix the max satisfy version (n.x) in grandfather's deps
closes #49
- Loading branch information
Showing
2 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,7 @@ function* _install(parentDir, pkg, options) { | |
// 4. link bin files | ||
// 5. link package to node_modules dir | ||
|
||
let grandfatherPkg; | ||
try { | ||
yield preinstall(realPkg, realPkgDir, options); | ||
// link bundleDependencies' bin | ||
|
@@ -142,6 +143,26 @@ function* _install(parentDir, pkg, options) { | |
if (bundledDependencies.indexOf(childPkg.name) !== -1) { | ||
continue; | ||
} | ||
// if version format "n.x", check grandfather's dependencies | ||
if (/^\d+\.x$/.test(childPkg.version)) { | ||
if (!grandfatherPkg) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fengmk2
via email
Author
Member
|
||
grandfatherPkg = yield utils.readJSON(path.join(parentDir, 'package.json')); | ||
} | ||
const version = grandfatherPkg.dependencies && grandfatherPkg.dependencies[childPkg.name]; | ||
if (version && /^[~\^]\d+\.\d+\.\d+$/.test(version)) { | ||
if (semver.satisfies(version.substring(1), childPkg.version)) { | ||
options.console.info('[%s] use grandfather(%s@%s)\'s dependencies version: %j instead of %j, parent: %s@%s', | ||
chalk.yellow(`${childPkg.name}@${childPkg.version}`), | ||
grandfatherPkg.name, | ||
grandfatherPkg.version, | ||
version, | ||
childPkg.version, | ||
realPkg.name, | ||
realPkg.version); | ||
childPkg.version = version; | ||
} | ||
} | ||
} | ||
tasks.push(install(realPkgDir, childPkg, options)); | ||
} | ||
yield tasks; | ||
|
理论上应该支持无限嵌套级别