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

Function getPublishes

scripts/publish.js:50–91  ·  view source on GitHub ↗
({ force })

Source from the content-addressed store, hash-verified

48}
49
50const getPublishes = async ({ force }) => {
51 const publishPackages = []
52
53 for (const { pkg, pkgPath } of await cli.mapWorkspaces({ public: true })) {
54 const updatePkg = async (cb) => {
55 const data = JSON.parse(await fs.readFile(pkgPath, 'utf8'))
56 const result = cb(data)
57 await fs.writeFile(pkgPath, JSON.stringify(result, null, 2))
58 return result
59 }
60
61 if (force || await versionNotExists(pkg)) {
62 publishPackages.push({
63 workspace: `--workspace=${pkg.name}`,
64 name: pkg.name,
65 version: pkg.version,
66 dependencies: pkg.dependencies,
67 devDependencies: pkg.devDependencies,
68 tag: await getWorkspaceTag(pkg),
69 updatePkg,
70 })
71 }
72 }
73
74 if (force || await versionNotExists(cli)) {
75 publishPackages.push({
76 workspace: '',
77 name: cli.name,
78 version: cli.version,
79 tag: `next-${semver.major(cli.version)}`,
80 dependencies: cli.dependencies,
81 devDependencies: cli.devDependencies,
82 updatePkg: async (cb) => {
83 const result = cb(cli)
84 await fs.writeFile(cliPath, JSON.stringify(result, null, 2))
85 return result
86 },
87 })
88 }
89
90 return publishPackages
91}
92
93const main = async (opts) => {
94 const { test, otp, dryRun, smokePublish, packDestination } = opts

Callers 1

mainFunction · 0.85

Calls 3

versionNotExistsFunction · 0.85
getWorkspaceTagFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected