Skip to content

Commit

Permalink
Add support for pnpm (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
admmasters committed Jun 16, 2020
1 parent e837544 commit fc2817a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,6 @@ concurrently([
So *null* means the process didn't terminate normally. This will make **concurrent**
to return non-zero exit code too.

* Does this work with the npm-replacement [yarn](https://github.com/yarnpkg/yarn)?
* Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn) or [pnpm](https://pnpm.js.org/)?

Yes! In all examples above, you may replace "`npm`" with "`yarn`".
Yes! In all examples above, you may replace "`npm`" with "`yarn`" or "`pnpm`".
2 changes: 1 addition & 1 deletion src/command-parser/expand-npm-shortcut.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = class ExpandNpmShortcut {
parse(commandInfo) {
const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn):(\S+)(.*)/) || [];
const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn|pnpm):(\S+)(.*)/) || [];
if (!cmdName) {
return commandInfo;
}
Expand Down
2 changes: 1 addition & 1 deletion src/command-parser/expand-npm-shortcut.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ it('returns same command if no npm: prefix is present', () => {
expect(parser.parse(commandInfo)).toBe(commandInfo);
});

for (const npmCmd of ['npm', 'yarn']) {
for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
describe(`with ${npmCmd}: prefix`, () => {
it(`expands to "${npmCmd} run <script> <args>"`, () => {
const commandInfo = {
Expand Down
2 changes: 1 addition & 1 deletion src/command-parser/expand-npm-wildcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class ExpandNpmWildcard {
}

parse(commandInfo) {
const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn) run (\S+)([^&]*)/) || [];
const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn|pnpm) run (\S+)([^&]*)/) || [];
const wildcardPosition = (cmdName || '').indexOf('*');

// If the regex didn't match an npm script, or it has no wildcard,
Expand Down
2 changes: 1 addition & 1 deletion src/command-parser/expand-npm-wildcard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ it('expands to nothing if no scripts exist in package.json', () => {
expect(parser.parse({ command: 'npm run foo-*-baz qux' })).toEqual([]);
});

for (const npmCmd of ['npm', 'yarn']) {
for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
describe(`with an ${npmCmd}: prefix`, () => {
it('expands to all scripts matching pattern', () => {
readPkg.mockReturnValue({
Expand Down

0 comments on commit fc2817a

Please sign in to comment.