MCPcopy
hub / github.com/vercel/next.js / install

Function install

packages/create-next-app/helpers/install.ts:11–50  ·  view source on GitHub ↗
(
  /** Indicate which package manager to use. */
  packageManager: PackageManager,
  /** Indicate whether there is an active Internet connection.*/
  isOnline: boolean
)

Source from the content-addressed store, hash-verified

9 * @returns A Promise that resolves once the installation is finished.
10 */
11export async function install(
12 /** Indicate which package manager to use. */
13 packageManager: PackageManager,
14 /** Indicate whether there is an active Internet connection.*/
15 isOnline: boolean
16): Promise<void> {
17 const args: string[] = ['install']
18 if (!isOnline) {
19 console.log(
20 yellow('You appear to be offline.\nFalling back to the local cache.')
21 )
22 args.push('--offline')
23 }
24 /**
25 * Return a Promise that resolves once the installation is finished.
26 */
27 return new Promise((resolve, reject) => {
28 /**
29 * Spawn the installation process.
30 */
31 const child = spawn(packageManager, args, {
32 stdio: 'inherit',
33 env: {
34 ...process.env,
35 ADBLOCK: '1',
36 // we set NODE_ENV to development as pnpm skips dev
37 // dependencies when production
38 NODE_ENV: 'development',
39 DISABLE_OPENCOLLECTIVE: '1',
40 },
41 })
42 child.on('close', (code) => {
43 if (code !== 0) {
44 reject({ command: `${packageManager} ${args.join(' ')}` })
45 return
46 }
47 resolve()
48 })
49 })
50}

Callers 2

createAppFunction · 0.90
installTemplateFunction · 0.90

Calls 8

yellowFunction · 0.85
pushMethod · 0.65
spawnFunction · 0.50
rejectFunction · 0.50
resolveFunction · 0.50
logMethod · 0.45
onMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected