({
destPath,
installCommand,
spawnOpts,
projectCreatedAt,
}: {
destPath: string;
installCommand: string;
spawnOpts?: SpawnOptions;
projectCreatedAt?: number;
})
| 1502 | } |
| 1503 | |
| 1504 | export async function runCustomInstallCommand({ |
| 1505 | destPath, |
| 1506 | installCommand, |
| 1507 | spawnOpts, |
| 1508 | projectCreatedAt, |
| 1509 | }: { |
| 1510 | destPath: string; |
| 1511 | installCommand: string; |
| 1512 | spawnOpts?: SpawnOptions; |
| 1513 | projectCreatedAt?: number; |
| 1514 | }): Promise<boolean> { |
| 1515 | const normalizedPath = path.normalize(destPath); |
| 1516 | |
| 1517 | const { alreadyInstalled, runNpmInstallSet } = checkIfAlreadyInstalled( |
| 1518 | customInstallCommandSet, |
| 1519 | normalizedPath |
| 1520 | ); |
| 1521 | customInstallCommandSet = runNpmInstallSet; |
| 1522 | |
| 1523 | if (alreadyInstalled) { |
| 1524 | debug( |
| 1525 | `Skipping custom install command for ${normalizedPath} because it was already run` |
| 1526 | ); |
| 1527 | return false; |
| 1528 | } |
| 1529 | |
| 1530 | // Skip if VERCEL_INSTALL_COMPLETED is set (e.g., for vercel.ts config compilation) |
| 1531 | // Path is already marked as installed above, allowing subdirectory installs to proceed |
| 1532 | if (process.env.VERCEL_INSTALL_COMPLETED === '1') { |
| 1533 | debug( |
| 1534 | `Skipping custom install command for ${normalizedPath} because VERCEL_INSTALL_COMPLETED is set` |
| 1535 | ); |
| 1536 | return false; |
| 1537 | } |
| 1538 | |
| 1539 | console.log(`Running "install" command: \`${installCommand}\`...`); |
| 1540 | const { |
| 1541 | cliType, |
| 1542 | lockfileVersion, |
| 1543 | packageJson, |
| 1544 | packageJsonPackageManager, |
| 1545 | turboSupportsCorepackHome, |
| 1546 | } = await scanParentDirs(destPath, true); |
| 1547 | const env = getEnvForPackageManager({ |
| 1548 | cliType, |
| 1549 | lockfileVersion, |
| 1550 | packageJsonPackageManager, |
| 1551 | env: spawnOpts?.env || {}, |
| 1552 | packageJsonEngines: packageJson?.engines, |
| 1553 | turboSupportsCorepackHome, |
| 1554 | projectCreatedAt, |
| 1555 | }); |
| 1556 | debug(`Running with $PATH:`, env?.PATH || ''); |
| 1557 | await execCommand(installCommand, { |
| 1558 | ...spawnOpts, |
| 1559 | env, |
| 1560 | cwd: destPath, |
| 1561 | }); |
nothing calls this directly
no test coverage detected