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

Support for Custom Publish Hooks #363

Closed
privatenumber opened this issue Mar 11, 2019 · 5 comments
Closed

Support for Custom Publish Hooks #363

privatenumber opened this issue Mar 11, 2019 · 5 comments

Comments

@privatenumber
Copy link
Contributor

Could there be a way to extend the publish steps? For example, a .nprc.js file that allows you to mutate the tasks array before it's executed.

@itaisteinherz
Copy link
Collaborator

a .nprc.js file

See #279 and #354.

allows you to mutate the tasks array before it's executed

What do you mean by that? You can already use npm hooks. Also see #347 (comment) and #344.

@privatenumber
Copy link
Contributor Author

Ah nice, thank you.

I have a repro that distributes a front-end library, and per release, I'd like to build the code w/ Webpack.

  1. I'd like a step that reflects this build (not as a hook)
  2. I'd also like for this step to happen before npm test but not in pretest. This is because npm test will build the code in dev mode by default, but if a flag is set, it will use built files. Basically, I don't want test scripts to manage the build of the repo.

@privatenumber
Copy link
Contributor Author

I'm hoping for something like this:

.nprc.js

module.exports = function (tasks) {
   tasks.splice(3, 0, {
      title: 'Webpack build',
      task: () => exec('npm run build')
   });
   return tasks;
};

@itaisteinherz
Copy link
Collaborator

I'm hoping for something like this:

I don't think that such syntax is going to be supported any time soon, since np does a lot of things under-the-hood and aside from the raw listr tasks to make publishing easier, and we'll probably keep it this way (with the purpose of keeping np self-contained and easy-to-use).
What we might support in the future is external plugins (which would mean that np would become more of a publish system rather than a tool).

For now, I think that your best option is to split the test script to test:dev and test:prod scripts. You can then have the test script run one of those, depending on the value of NODE_ENV (or any other setting you prefer).

@itaisteinherz
Copy link
Collaborator

Closing as future discussion on this should be in #386.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants