Skip to content
Open
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
13 changes: 13 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,23 @@
"pnpm",
"init"
],
[
"pn",
"init"
],
[
"pnpx"
],
[
"pnx"
],
[
"pnpm",
"dlx"
],
[
"pn",
"dlx"
]
]
},
Expand Down Expand Up @@ -96,7 +107,9 @@
">=11.0.0": {
"url": "https://registry.npmjs.org/pnpm/-/pnpm-{}.tgz",
"bin": {
"pn": "./bin/pnpm.mjs",
"pnpm": "./bin/pnpm.mjs",
"pnx": "./bin/pnpx.mjs",
"pnpx": "./bin/pnpx.mjs"
},
"registry": {
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@
"publishConfig": {
"bin": {
"corepack": "./dist/corepack.js",
"pn": "./dist/pn.js",
"pnpm": "./dist/pnpm.js",
"pnx": "./dist/pnx.js",
"pnpx": "./dist/pnpx.js",
"yarn": "./dist/yarn.js",
"yarnpkg": "./dist/yarnpkg.js"
},
"executableFiles": [
"./dist/npm.js",
"./dist/npx.js",
"./dist/pn.js",
"./dist/pnpm.js",
"./dist/pnx.js",
"./dist/pnpx.js",
"./dist/yarn.js",
"./dist/yarnpkg.js",
Expand All @@ -81,8 +85,12 @@
"./shims/npm.ps1",
"./shims/npx",
"./shims/npx.ps1",
"./shims/pn",
"./shims/pn.ps1",
"./shims/pnpm",
"./shims/pnpm.ps1",
"./shims/pnx",
"./shims/pnx.ps1",
"./shims/pnpx",
"./shims/pnpx.ps1",
"./shims/yarn",
Expand Down
26 changes: 26 additions & 0 deletions tests/Enable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@ describe(`EnableCommand`, () => {
});
});

it(`should add pnpm alias binaries`, async () => {
await xfs.mktempPromise(async cwd => {
const corepackBin = await makeBin(cwd, `corepack` as Filename);

await expect(runCli(cwd, [`enable`, `--install-directory=${npath.fromPortablePath(cwd)}`, `pnpm`])).resolves.toMatchObject({
stdout: ``,
stderr: ``,
exitCode: 0,
});

const sortedEntries = xfs.readdirPromise(cwd).then(entries => {
return entries.sort();
});

const expectedEntries: Array<string> = [
ppath.basename(corepackBin),
...getBinaryNames(`pn`),
...getBinaryNames(`pnpm`),
...getBinaryNames(`pnpx`),
...getBinaryNames(`pnx`),
];

await expect(sortedEntries).resolves.toEqual(expectedEntries.sort());
});
});

test.skipIf(process.platform === `win32`)(`should overwrite existing files`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeFilePromise(ppath.join(cwd, `yarn`), `hello`);
Expand Down
18 changes: 18 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,24 @@ it(`should allow using transparent commands on npm-configured projects`, async (
});
});

it(`should allow using pnpm alias transparent commands on npm-configured projects`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
packageManager: `npm@6.14.2`,
});

await expect(runCli(cwd, [`pn`, `dlx`, `--help`])).resolves.toMatchObject({
exitCode: 0,
stderr: ``,
});

await expect(runCli(cwd, [`pnx`, `--help`])).resolves.toMatchObject({
exitCode: 0,
stderr: ``,
});
});
});

it(`should transparently use the preconfigured version when there is no local project`, async () => {
await xfs.mktempPromise(async cwd => {
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
Expand Down