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

Function getWorkspaceTag

scripts/publish.js:13–35  ·  view source on GitHub ↗
({ name, version })

Source from the content-addressed store, hash-verified

11const op = () => spawn('op', 'item', 'get', 'npm', '--otp', { out: true, ok: true })
12
13const getWorkspaceTag = async ({ name, version }) => {
14 const { prerelease, major } = semver.parse(version)
15 if (prerelease.length) {
16 return 'prerelease'
17 }
18
19 const pack = await pacote.packument(name, { preferOnline: true }).catch(() => null)
20
21 if (!pack) {
22 // This might never happen but if we were to create a new workspace that has never
23 // been published before it should be set to latest right away.
24 return 'latest'
25 }
26
27 if (major >= semver.major(pack['dist-tags'].latest)) {
28 // if the major version we are publishing is greater than the major version
29 // of the latest dist-tag, then this should be latest too
30 return 'latest'
31 }
32
33 // Anything else is a backport
34 return 'backport'
35}
36
37const versionNotExists = async ({ name, version }) => {
38 const spec = `${name}@${version}`

Callers 1

getPublishesFunction · 0.85

Calls 2

parseMethod · 0.80
packumentMethod · 0.80

Tested by

no test coverage detected