MCPcopy
hub / github.com/tailwindlabs/tailwindcss / add

Function add

packages/@tailwindcss-upgrade/src/utils/packages.ts:30–55  ·  view source on GitHub ↗
(packages: string[], location: 'dependencies' | 'devDependencies' = 'dependencies')

Source from the content-addressed store, hash-verified

28 return await packageManagerForBase.get(base)
29 },
30 async add(packages: string[], location: 'dependencies' | 'devDependencies' = 'dependencies') {
31 let packageManager = await packageManagerForBase.get(base)
32 let args = packages.slice()
33 if (location === 'devDependencies') {
34 args.push(SAVE_DEV[packageManager] || SAVE_DEV.default)
35 }
36
37 // Allow running the `pnpm` command in the workspace root without
38 // erroring. Can't just use `--workspace-root` because that will force
39 // install dependencies in the workspace root.
40 if (packageManager === 'pnpm') {
41 args.push('--ignore-workspace-root-check')
42 }
43
44 let command = `${packageManager} add ${args.join(' ')}`
45 try {
46 return await exec(command, { cwd: base })
47 } catch (e: any) {
48 error(`An error occurred while running \`${command}\`\n\n${e.stdout}\n${e.stderr}`, {
49 prefix: '↳ ',
50 })
51 throw e
52 } finally {
53 manifests.delete(base)
54 }
55 },
56 has(name: string) {
57 return manifests.get(base).includes(`"${name}":`)
58 },

Callers

nothing calls this directly

Calls 3

errorFunction · 0.90
execFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected