Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check.js: Ignore dedup warnings for bundled dependencies #3337

Merged
merged 1 commit into from
May 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions __tests__/commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,12 @@ test.concurrent('--integrity --check-files should not die on broken symlinks', a
},
);
});

test.concurrent('should ignore bundled dependencies',
async (): Promise<void> => {
await runInstall({}, path.join('..', 'check', 'bundled-dep-check'),
async (config, reporter, install, getStdout): Promise<void> => {
await checkCmd.run(config, reporter, {}, []);
expect(getStdout().indexOf('warning')).toEqual(-1);
});
});
Binary file not shown.
9 changes: 9 additions & 0 deletions __tests__/fixtures/check/bundled-dep-check/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "bundled-dep-check",
"description": "A package with bundled dependencies",
"version": "2.0.1",
"dependencies": {
"nyc": "file:./nyc-10.3.2.tgz"
},
"license": "MIT"
}
13 changes: 13 additions & 0 deletions __tests__/fixtures/check/bundled-dep-check/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


archy@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40"

"nyc@file:./nyc-10.3.2.tgz":
version "10.3.2"
resolved "./nyc-10.3.2.tgz#35563cb271637e2dc922a1145d8981e948a9f5c3"
dependencies:
archy "^1.0.0"
14 changes: 10 additions & 4 deletions src/cli/commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
}
}

const bundledDeps = {};
// check if any of the node_modules are out of sync
const res = await install.linker.getFlatHoistedTree(patterns);
for (const [loc, {originalKey, pkg, ignore}] of res) {
Expand Down Expand Up @@ -268,6 +269,7 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
}

const deps = Object.assign({}, packageJson.dependencies, packageJson.peerDependencies);
bundledDeps[packageJson.name] = packageJson.bundledDependencies || [];

for (const name in deps) {
const range = deps[name];
Expand Down Expand Up @@ -321,10 +323,14 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
}

const packageJson = await config.readJson(loc);
if (
packageJson.version === depPkg.version ||
(semver.satisfies(packageJson.version, range, config.looseSemver) &&
semver.gt(packageJson.version, depPkg.version, config.looseSemver))
const packagePath = originalKey.split('#');
const rootDep = packagePath[0];
const packageName = packagePath[1] || packageJson.name;

const bundledDep = bundledDeps[rootDep] && bundledDeps[rootDep].includes(packageName);
if (!bundledDep && (packageJson.version === depPkg.version ||
(semver.satisfies(packageJson.version, range, config.looseSemver) &&
semver.gt(packageJson.version, depPkg.version, config.looseSemver)))
) {
reporter.warn(
reporter.lang(
Expand Down