Skip to content

postinstall script causes havoc if wire is not the root module #99

Closed
scothis opened this Issue May 7, 2013 · 10 comments

2 participants

@scothis
The Javascript Architectural Toolkit member
scothis commented May 7, 2013

When using npm to install wire as a dependency of another project, the post install script executes and causes all sorts of fun. I assume this is only intended to run for developer working on wire and not consumers of wire.

@briancavalier
The Javascript Architectural Toolkit member

On dev, right? Any suggestions on how to automagically/easily install wire's own deps for development, and also prevent this chaos when installing wire as a dep of another project?

@scothis
The Javascript Architectural Toolkit member
scothis commented May 7, 2013

yep, on dev. At one point I thought there was a postdevinstall, but I don't see it now... Perhaps invoke a proper script that sniffs the env before proceeding

@briancavalier
The Javascript Architectural Toolkit member

Yeah. Another option might be to have an npm script install-devdeps or something that people can run manually when setting up their dev env.

@scothis
The Javascript Architectural Toolkit member
scothis commented May 7, 2013

There are a ton of env vars npm adds when exec'ing the script, I'm sure there's something we can sniff

@scothis
The Javascript Architectural Toolkit member
scothis commented May 7, 2013

The envvars are not helpful. The best sniff I can come up with is to check if the working dir is under node_modules

@briancavalier
The Javascript Architectural Toolkit member

Bummer. Stinks that there's no easy way to do this, postdevinstall sounds like it would have been perfect.

Hmmm, looking at the npm script docs, I wonder if prepublish would work. It says it will be run when doing npm install with no args. We'd have to filter the submodule and bower install dirs using .npmignore, but sounds like it may work. I'll give it a go today.

@briancavalier
The Javascript Architectural Toolkit member

Ok, prepublish seems to do what we want, but def will be good for someone else to try! Here's what I've observed:

  1. If I simulate npm publish by instead doing npm pack, the prepublish script is executed: bower components are installed, and submodules are updated before the tgz is created. The tgz does not contain the bower components or submodules, since they are listed in .npmignore. So far so good.
  2. Then, in some other dir, if I run npm install <path to npm packed wire tgz>, the wire node package is installed into node_modules, and the prepublish script is not executed: bower components are not installed, and submodules are not fetched. Still good.
  3. If I clone wire and checkout the npm-prepublish branch, then run npm install, node deps and bower components are installed, and submodules are fetched. Yay.

Seems like it works, but def need someone else to verify!

@scothis
The Javascript Architectural Toolkit member
scothis commented May 8, 2013

I can confirm the prepublish script is not exec'ed when installing as a dependency.

@briancavalier
The Javascript Architectural Toolkit member

Cool, thanks, I'll merge this back into dev.

@briancavalier
The Javascript Architectural Toolkit member

Fixed by bb4bb89

@briancavalier briancavalier was assigned May 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.