Does npm publish perform an npm pack
Asked Answered
H

1

14

Considering the Node.js package manager, namely npm - I was curious if the publish command performs the pack command prior to the publish or if it does something different altogether? So if I were to execute:

npm publish <folder>

Does it first perform the following:

npm pack <folder>

I was unable to find anything mentioned in the documentation.


The primary reason I'm curious about this is that our build process is simply doing the npm publish without the explicit npm pack prior, but the package doesn't appear to have the expected contents. i.e.; the contents of the .tgz differ when I perform a local npm pack to that of the contents of the npm publish.
Haws answered 13/5, 2016 at 14:5 Comment(1)
what kind of difference you have?Anthropogeography
H
4

Having a look at the NPM source you can see that it arrives in the publishFromDirectory function, and calls into the pack module.

https://github.com/npm/npm/blob/b80d650def417645d2525863e9f17af57a917b42/lib/publish.js#L79 and again at https://github.com/npm/npm/blob/b80d650def417645d2525863e9f17af57a917b42/lib/publish.js#L88

If you follow through into the pack module, you can see that the _pack function performs the same 2 steps:

https://github.com/npm/npm/blob/114d518c75732c42acbef3acab36ba1d0fd724e2/lib/pack.js#L67

So, to answer your question, it doesn't do exactly pack <folder> but does call into the same major code paths.

The code there is mostly well written and not difficult to follow, I would encourage you to dig into the source code of these projects for this type of question as your knowledge on the tools you are using will explode if you do.

Homozygote answered 22/12, 2017 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.