Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Documentation on API usage #19

Open
smfoote opened this issue Jun 7, 2018 · 1 comment
Open

Documentation on API usage #19

smfoote opened this issue Jun 7, 2018 · 1 comment

Comments

@smfoote
Copy link

smfoote commented Jun 7, 2018

Hi there - I stumbled on this project as I was trying to replicate some of the features in Lerna.js. As I was reading their source code, I found npm-lifecycle. Is there documentation on how to use the API? I will describe my specific problem below, but I think general API documentation would be super helpful.

My problem: I'm trying to set up a monorepo that will work with my company's build tooling, which uses a private NPM registry. As such, I need to npm pack but not npm publish each of the "packages" within the monorepo, then let the tooling handle the actual publishing. I have set up a script to (eventually) automate the npm packing of each package, but nothing I try seems to work. Since Lerna is essentially doing the same thing with lerna publish --skip-npm I figured I would see what they are doing.

However, the when I use npm-lifecycle to npm pack, the process silently fails because my packages don't have .hooks directories (Should they? Is that an expected directory in an NPM package? How do I create it?).

Some documentation on basic (or advanced) usage would really help me out. Thanks!

@isaacs
Copy link
Contributor

isaacs commented Jul 17, 2019

The line you linked to isn't it silently failing, it's silently doing nothing, because there's no hook and no script for that lifecycle stage.

A lifecycle hook is an ancient and not very widely known feature of npm, dating back to even earlier than the node_modules folder itself.

The hook script in this case would be something like ./node_modules/.hooks/install. If there's an executable script there, it'll get run on any install lifecycle event in that repo.

If there's no hook file, and no script for that lifecycle event in package.json, then there's nothing to do. The early return is there to avoid doing the work to build up the environment for a child process, since that can be taxing.

Yes, more docs would be much appreciated on this module.

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

No branches or pull requests

2 participants