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

Injects a "process.versions.pnp" variable #6464

Merged
merged 2 commits into from Oct 2, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

[#6449](https://github.com/yarnpkg/yarn/pull/6449) - [**Maël Nison**](https://twitter.com/arcanis)

- Makes the PnP hook inject a `process.versions.pnp` variable when setup (equals to `VERSIONS.std`)

[#6464](https://github.com/yarnpkg/yarn/pull/6464) - [**Maël Nison**](https://twitter.com/arcanis)

- Fixes the display name of the faulty package when the NPM registry returns corrupted data

[#6455](https://github.com/yarnpkg/yarn/pull/6455) - [**Grey Baker**](https://github.com/greysteil)
Expand Down
15 changes: 14 additions & 1 deletion packages/pkg-tests/pkg-tests-specs/sources/pnp.js
Expand Up @@ -523,7 +523,7 @@ module.exports = makeTemporaryEnv => {
test(
`it should export the PnP API through the 'pnpapi' name`,
makeTemporaryEnv(
{dependencies: {[`no-deps`]: `1.0.0`}},
{},
{
plugNPlay: true,
},
Expand All @@ -535,6 +535,19 @@ module.exports = makeTemporaryEnv => {
),
);

test(
`it should expose the PnP version through 'process.versions.pnp'`,
makeTemporaryEnv({}, {plugNPlay: true}, async ({path, run, source}) => {
await run(`install`);

const pnpapiVersionsStd = await source(`require('pnpapi').VERSIONS.std`);
const processVersionsPnp = await source(`process.versions.pnp`);

await expect(typeof processVersionsPnp).toEqual(`string`);
await expect(processVersionsPnp).toEqual(String(pnpapiVersionsStd));
}),
);

test(
`it should not update the installConfig.pnp field of the package.json when installing with an environment override`,
makeTemporaryEnv(
Expand Down
2 changes: 2 additions & 0 deletions src/util/generate-pnp-map-api.tpl.js
Expand Up @@ -677,6 +677,8 @@ exports.setup = function setup() {

return false;
};

process.versions.pnp = String(exports.VERSIONS.std);
};

exports.setupCompatibilityLayer = () => {
Expand Down