Skip to content

lerna exec, lerna run and scoping#152

Merged
jamiebuilds merged 22 commits intolerna:masterfrom
joscha:lerna-exec-lerna-run-and-restrict
Jun 9, 2016
Merged

lerna exec, lerna run and scoping#152
jamiebuilds merged 22 commits intolerna:masterfrom
joscha:lerna-exec-lerna-run-and-restrict

Conversation

@joscha
Copy link
Copy Markdown
Contributor

@joscha joscha commented May 20, 2016

This introduces an abstract command named ScopedCommand which adheres to a given CLI flag named scope that allows to scope the lerna run and lerna exec command (I pulled both #145 and #151) into this PR to a subset of packages by giving a glob that matches the package name.

After merging this, the following can be used:

  • lerna run --scope my-component-* prepublish
  • lerna exec --scope my-component-* -- ls -la node_modules

fixes #143
closes #145
fixes #150
closes #151

@thejameskyle PTAL
@eirslett @jpnelson FYI

joscha and others added 12 commits May 19, 2016 07:05
As opposed to 'lerna run', which runs
scripts defined in package.json, exec will
let you execute an inbuilt npm command directly
in each package, e.g.

- `lerna exec rebuild`
- `lerna exec publish`
- `lerna exec upgrade`
It should run any command, not just
an npm command.
@joscha joscha changed the title Lerna exec lerna run and restrict lerna exec, lerna run and scoping May 20, 2016
Comment thread src/ScopedCommand.js Outdated
import Command from "./Command";
import minimatch from "minimatch";

export default class ScopedCommand extends Command {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if inheritance is the best way to solve this. It should be just as easy to have a util that does this and it will get us away from using inheritance which complicates things

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is the perfect problem to be solved by inheritance. Especially as then the concerns are also clearly separated for the tests as well, but I am happy to change it to whatever form you like it in order to get it integrated. Would you like me to change it to a helper?

@jamiebuilds
Copy link
Copy Markdown
Contributor

I do like the --scope name for this, nice suggestion.

@joscha
Copy link
Copy Markdown
Contributor Author

joscha commented May 25, 2016

@thejameskyle is there anything I can do to help this getting integrated into lerna? Would you like to me to change the inheritance-based code into a helper?

@jamiebuilds
Copy link
Copy Markdown
Contributor

Sorry, I've fallen behind on reviewing PRs because of other stuff going on right now.

I would personally prefer using a helper for created a scoped set of packages using mini-match. The only reason I'm using inheritance today is to create a shared interface for every command.

@joscha
Copy link
Copy Markdown
Contributor Author

joscha commented May 26, 2016

@thejameskyle I changed the implementation to use a helper. Just on a side note, I think it was a bit cleaner with inheritance. Anyway, the changes are in 5dd9e9f - I hope that brings it in a mergeable state.

@paulyoung
Copy link
Copy Markdown

I'd love to be able to use this functionality. Is there anything I can do to help here?

@joscha
Copy link
Copy Markdown
Contributor Author

joscha commented Jun 7, 2016

@paulyoung I don't think so - last time I talked to @thejameskyle he was just preoccupied with other things - maybe that little github email nudge will bring him back 😉

@jamiebuilds
Copy link
Copy Markdown
Contributor

maybe that little github email nudge will bring him back

lol, I don't think you understand how many notifications I get 😜

I'm happy with this

@jamiebuilds jamiebuilds merged commit 7e50a36 into lerna:master Jun 9, 2016
@joscha joscha deleted the lerna-exec-lerna-run-and-restrict branch June 9, 2016 02:01
@hzoo
Copy link
Copy Markdown
Contributor

hzoo commented Jun 9, 2016

Awesome! @joscha can you do a doc pr (or i'll do it later)

@joscha
Copy link
Copy Markdown
Contributor Author

joscha commented Jun 9, 2016

@hzoo will do one - give me a few minutes!

@joscha joscha mentioned this pull request Jun 9, 2016
@joscha
Copy link
Copy Markdown
Contributor Author

joscha commented Jun 9, 2016

@hzoo its in #197 - I also found that the concurrency PR #163 was merged in the meantime, so I added a fix that re-uses concurrency in the code that was just merged.

@acostaf
Copy link
Copy Markdown

acostaf commented Sep 17, 2018

Reopen please --scope is not working on "lerna": "^3.4.0"

npm run this "build:dep": "lerna run --scope common build"

I get lerna ERR! EFILTER No packages remain after filtering [ 'common' ]

my Lerna file
"packages": [
"common",
...
],

@evocateur
Copy link
Copy Markdown
Member

@acostaf please open a new issue with complete reproduction details, thanks

@lock
Copy link
Copy Markdown

lock Bot commented Dec 27, 2018

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm run uses exec, rather than an async exec Allow running command for a specific package

6 participants