MCPcopy Create free account
hub / github.com/npm/cli / createNodeTarball

Function createNodeTarball

scripts/create-node-pr.js:16–59  ·  view source on GitHub ↗
({ mani, registryOnly, localTest, tag, dir: extractDir })

Source from the content-addressed store, hash-verified

14const gitNode = spawn.create('git', { cwd: NODE_DIR })
15
16const createNodeTarball = async ({ mani, registryOnly, localTest, tag, dir: extractDir }) => {
17 const tarball = join(extractDir, 'npm-node.tgz')
18 await pacote.tarball.file(mani._from, tarball, { resolved: mani._resolved })
19
20 if (registryOnly) {
21 // a future goal is to only need files from the published tarball for
22 // inclusion in node. in that case, we'd be able to remove everything after
23 // this line since we have already fetched the tarball
24 return tarball
25 }
26
27 // extract tarball to current dir and delete original tarball
28 await tar.x({ strip: 1, file: tarball, cwd: extractDir })
29 await fs.rimraf(tarball)
30
31 // checkout the tag since we need to get files from source.
32 if (!localTest) {
33 try {
34 await git('checkout', tag)
35 } catch (err) {
36 log.error('Use the `--local-test` flag to avoid checking out the tag')
37 throw err
38 }
39 }
40 // currently there is an empty .npmrc file in the deps/npm dir in the node repo
41 // i do not know why and it might not be used but in order to minimize any
42 // unnecessary churn, let's create that file to match the old process
43 await fsp.writeFile(join(extractDir, '.npmrc'), '', 'utf-8')
44
45 // copy our test dirs so that tests can be run
46 for (const path of ['tap-snapshots/', 'test/']) {
47 await cp(join(CWD, path), join(extractDir, path), { recursive: true })
48 }
49
50 // recreate the tarball as closely as possible to how we would before publishing
51 // to the registry. the only difference here is the extra files we put in the dir
52 await tar.c({
53 ...pacote.DirFetcher.tarCreateOptions(mani),
54 cwd: extractDir,
55 file: tarball,
56 }, ['.'])
57
58 return tarball
59}
60
61const getPrBody = async ({ releases, closePrs }) => {
62 const useSummary = releases.length > 1

Callers 1

mainFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected