Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] Use getNodeBinPaths() in vc dev #10225

Merged
merged 4 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/late-bobcats-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vercel': patch
---

Use `getNodeBinPaths()` in `vc dev`
8 changes: 5 additions & 3 deletions packages/cli/src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ export default async function dev(

let projectSettings: ProjectSettings | undefined;
let envValues: Record<string, string> = {};
let repoRoot: string | undefined;
if (link.status === 'linked') {
const { project, org, repoRoot } = link;
const { project, org } = link;

// If repo linked, update `cwd` to the repo root
if (repoRoot) {
cwd = repoRoot;
if (link.repoRoot) {
repoRoot = cwd = link.repoRoot;
}

client.config.currentTeam = org.type === 'team' ? org.id : undefined;
Expand All @@ -82,6 +83,7 @@ export default async function dev(
output,
projectSettings,
envValues,
repoRoot,
});

// listen to SIGTERM for graceful shutdown
Expand Down
11 changes: 7 additions & 4 deletions packages/cli/src/util/dev/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
Builder,
cloneEnv,
Env,
getNodeBinPath,
getNodeBinPaths,
StartDevServerResult,
FileFsRef,
PackageJson,
Expand Down Expand Up @@ -124,6 +124,7 @@ function sortBuilders(buildA: Builder, buildB: Builder) {

export default class DevServer {
public cwd: string;
public repoRoot: string;
public output: Output;
public proxy: httpProxy;
public envConfigs: EnvConfigs;
Expand Down Expand Up @@ -169,6 +170,7 @@ export default class DevServer {

constructor(cwd: string, options: DevServerOptions) {
this.cwd = cwd;
this.repoRoot = options.repoRoot ?? cwd;
this.output = options.output;
this.envConfigs = { buildEnv: {}, runEnv: {}, allEnv: {} };
this.envValues = options.envValues || {};
Expand Down Expand Up @@ -1412,7 +1414,7 @@ export default class DevServer {
files,
entrypoint: middleware.entrypoint,
workPath,
repoRootPath: this.cwd,
repoRootPath: this.repoRoot,
config: middleware.config || {},
meta: {
isDev: true,
Expand Down Expand Up @@ -1849,7 +1851,7 @@ export default class DevServer {
entrypoint: match.entrypoint,
workPath,
config: match.config || {},
repoRootPath: this.cwd,
repoRootPath: this.repoRoot,
meta: {
isDev: true,
requestPath,
Expand Down Expand Up @@ -2237,7 +2239,8 @@ export default class DevServer {
);

// add the node_modules/.bin directory to the PATH
const nodeBinPath = await getNodeBinPath({ cwd });
const nodeBinPaths = getNodeBinPaths({ base: this.repoRoot, start: cwd });
const nodeBinPath = nodeBinPaths.join(path.delimiter);
env.PATH = `${nodeBinPath}${path.delimiter}${env.PATH}`;

// This is necesary so that the dev command in the Project
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/util/dev/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface DevServerOptions {
output: Output;
projectSettings?: ProjectSettings;
envValues?: Record<string, string>;
repoRoot?: string;
}

export interface EnvConfigs {
Expand Down