Skip to content

Commit

Permalink
fix(plugin-nm): handle supportedArchitectures (#4343)
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz authored Apr 12, 2022
1 parent c1744ef commit 07c3421
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .yarn/versions/cb320125.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/plugin-nm": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The following changes only affect people writing Yarn plugins:
- applies hoisting algorithm on aliased dependencies
- reinstalls modules that have their directories removed from node_modules by the user
- improves portal hoisting
- supports `supportedArchitectures`

### Bugfixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1722,4 +1722,31 @@ describe(`Node_Modules`, () => {
});
}),
);

it(`should support supportedArchitectures`,
makeTemporaryEnv(
{
dependencies: {
native: `1.0.0`,
},
},
async ({path, run}) => {
await xfs.writeJsonPromise(ppath.join(path, Filename.rc), {
nodeLinker: `node-modules`,
supportedArchitectures: {
os: [`foo`],
cpu: [`x64`, `x86`],
},
});

await expect(run(`install`)).resolves.toMatchObject({code: 0});

await expect(xfs.readdirPromise(ppath.join(path, Filename.nodeModules))).resolves.toEqual([
`.yarn-state.yml`,
`native`,
`native-foo-x64`,
`native-foo-x86`,
]);
}),
);
});
2 changes: 1 addition & 1 deletion packages/plugin-nm/sources/NodeModulesLinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class NodeModulesInstaller implements Installer {
}

// We don't link the package at all if it's for an unsupported platform
if (!jsInstallUtils.checkManifestCompatibility(pkg))
if (!structUtils.isPackageCompatible(pkg, this.opts.project.configuration.getSupportedArchitectures()))
return {packageLocation: null, buildDirective: null};

const packageDependencies = new Map<string, string | [string, string] | null>();
Expand Down

0 comments on commit 07c3421

Please sign in to comment.