(forceRestart: boolean = false)
| 3025 | } |
| 3026 | |
| 3027 | async runDevCommand(forceRestart: boolean = false) { |
| 3028 | // In multi-service setup, all services are managed by orchestrator |
| 3029 | if (this.shouldUseServicesOrchestrator()) { |
| 3030 | return; |
| 3031 | } |
| 3032 | |
| 3033 | const { devCommand, cwd } = this; |
| 3034 | |
| 3035 | if (devCommand === this.currentDevCommand && !forceRestart) { |
| 3036 | // `devCommand` has not changed, so don't restart frontend dev process |
| 3037 | return; |
| 3038 | } |
| 3039 | |
| 3040 | this.currentDevCommand = devCommand; |
| 3041 | |
| 3042 | if (!devCommand) { |
| 3043 | return; |
| 3044 | } |
| 3045 | |
| 3046 | if (this.devProcess) { |
| 3047 | await treeKill(this.devProcess.pid!); |
| 3048 | } |
| 3049 | |
| 3050 | output.log(`Running Dev Command ${chalk.cyan.bold(`“${devCommand}”`)}`); |
| 3051 | |
| 3052 | const port = await getPort(); |
| 3053 | |
| 3054 | const env: Env = cloneEnv( |
| 3055 | { |
| 3056 | // Because of child process 'pipe' below, isTTY will be false. |
| 3057 | // Most frameworks use `chalk`/`supports-color` so we enable it anyway. |
| 3058 | FORCE_COLOR: process.stdout.isTTY ? '1' : '0', |
| 3059 | // Prevent framework dev servers from automatically opening a web |
| 3060 | // browser window, since it will not be the port that `vc dev` |
| 3061 | // is listening on and thus will be missing Vercel features. |
| 3062 | BROWSER: 'none', |
| 3063 | }, |
| 3064 | process.env, |
| 3065 | this.envConfigs.allEnv, |
| 3066 | { |
| 3067 | PORT: `${port}`, |
| 3068 | } |
| 3069 | ); |
| 3070 | |
| 3071 | // add the node_modules/.bin directory to the PATH |
| 3072 | const nodeBinPaths = getNodeBinPaths({ base: this.repoRoot, start: cwd }); |
| 3073 | const nodeBinPath = nodeBinPaths.join(path.delimiter); |
| 3074 | env.PATH = `${nodeBinPath}${path.delimiter}${env.PATH}`; |
| 3075 | |
| 3076 | // This is necesary so that the dev command in the Project |
| 3077 | // will work cross-platform (especially Windows). |
| 3078 | const command = devCommand |
| 3079 | .replace(/\$PORT/g, `${port}`) |
| 3080 | .replace(/%PORT%/g, `${port}`); |
| 3081 | |
| 3082 | injectNextDevWebSocketShimIfNeeded(env, command, this.projectSettings); |
| 3083 | |
| 3084 | output.debug( |
no test coverage detected