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

fix: check for cpu and os constraints if the arrays are not empty #2490

Merged
merged 2 commits into from
Jan 20, 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
22 changes: 15 additions & 7 deletions __tests__/commands/install/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,19 @@ test.concurrent('a subdependency of an optional dependency that fails should be
});

// disabled while fix is not merged
test.skip('should not loose dependencies when installing with --production',
(): Promise<void> => {
// revealed https://github.com/yarnpkg/yarn/issues/2263
return runInstall({production: true}, 'prod-should-keep-subdeps', async (config) => {
// would be hoisted from gulp/vinyl-fs/glob-stream/minimatch/brace-expansion/balanced-match
assert.equal(await getPackageVersion(config, 'balanced-match'), '0.4.2');
test.skip('should not loose dependencies when installing with --production',
(): Promise<void> => {
// revealed https://github.com/yarnpkg/yarn/issues/2263
return runInstall({production: true}, 'prod-should-keep-subdeps', async (config) => {
// would be hoisted from gulp/vinyl-fs/glob-stream/minimatch/brace-expansion/balanced-match
assert.equal(await getPackageVersion(config, 'balanced-match'), '0.4.2');
});
});

// https://github.com/yarnpkg/yarn/issues/2470
test.concurrent('a allows dependency with [] in os cpu requirements',
(): Promise<void> => {
return runInstall({}, 'empty-os', async (config) => {
assert(await fs.exists(path.join(config.cwd, 'node_modules', 'feed')));
});
});
});
5 changes: 5 additions & 0 deletions __tests__/fixtures/install/empty-os/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"feed": "0.3.0"
}
}
13 changes: 13 additions & 0 deletions __tests__/fixtures/install/empty-os/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


feed@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/feed/-/feed-0.3.0.tgz#65bcc4c9c57fde8e277faf4afff80c2d1d90e82d"
dependencies:
xml ">= 0.0.5"

"xml@>= 0.0.5":
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
20 changes: 12 additions & 8 deletions src/package-compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,20 @@ export default class PackageCompatibility {
}
};

if (!this.config.ignorePlatform && Array.isArray(info.os)) {
if (!PackageCompatibility.isValidPlatform(info.os)) {
pushError(this.reporter.lang('incompatibleOS', process.platform));
}
const invalidPlatform = !this.config.ignorePlatform &&
Array.isArray(info.os) &&
info.os.length > 0 &&
!PackageCompatibility.isValidPlatform(info.os);
if (invalidPlatform) {
pushError(this.reporter.lang('incompatibleOS', process.platform));
}

if (!this.config.ignorePlatform && Array.isArray(info.cpu)) {
if (!PackageCompatibility.isValidArch(info.cpu)) {
pushError(this.reporter.lang('incompatibleCPU', process.arch));
}
const invalidCpu = !this.config.ignorePlatform &&
Array.isArray(info.cpu) &&
info.cpu.length > 0 &&
!PackageCompatibility.isValidArch(info.cpu);
if (invalidCpu) {
pushError(this.reporter.lang('incompatibleCPU', process.arch));
}

if (!this.ignoreEngines && typeof info.engines === 'object') {
Expand Down