MCPcopy Index your code
hub / github.com/tinyhttp/tinyhttp / installPackages

Function installPackages

packages/cli/src/utils.ts:53–89  ·  view source on GitHub ↗
(pkg: string)

Source from the content-addressed store, hash-verified

51}
52
53export const installPackages = async (pkg: string) => {
54 // Edit package.json
55
56 const file = editPkgJson('package.json')
57
58 const allDeps = Object.keys(file.get('dependencies'))
59
60 // Replace "workspace:*" with "latest"
61
62 const thDeps = allDeps.filter((x) => x.startsWith('@tinyhttp'))
63
64 const newDeps = {}
65
66 for (const dep of thDeps) newDeps[dep] = 'latest'
67
68 file
69 .set('dependencies', {
70 ...file.get('dependencies'),
71 ...newDeps
72 })
73 .save()
74
75 const depCount =
76 (Object.keys(file.get('dependencies')) || []).length + (Object.keys(file.get('devDependencies')) || []).length
77
78 const spinner = ora()
79
80 spinner.start(colorette.cyan(`Installing ${depCount} package${depCount > 1 ? 's' : ''} with ${pkg} 📦`))
81
82 try {
83 await runCmd(`${pkg} ${pkg === 'yarn' ? 'add' : 'i'}`)
84 } catch {
85 throw new Error('Failed to install packages')
86 }
87
88 spinner.stop()
89}
90
91const ESLINT_JS_CONFIG = `
92{

Callers 1

index.tsFile · 0.90

Calls 3

saveMethod · 0.80
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected