[build-utils] Make repoRootPath non-optional (#7909)

This value is always set in the Vercel build infra, so mark the type as non-optional.
This commit is contained in:
Nathan Rajlich
2022-06-01 12:39:45 -07:00
committed by GitHub
parent 1c8f91031a
commit 960c66584c
6 changed files with 8 additions and 5 deletions

View File

@@ -82,7 +82,7 @@ export interface BuildOptions {
* is the Git Repository Root. This is only relevant for Monorepos. * is the Git Repository Root. This is only relevant for Monorepos.
* See https://vercel.com/blog/monorepos * See https://vercel.com/blog/monorepos
*/ */
repoRootPath?: string; repoRootPath: string;
/** /**
* An arbitrary object passed by the user in the build definition defined * An arbitrary object passed by the user in the build definition defined
@@ -123,7 +123,7 @@ export interface PrepareCacheOptions {
* is the Git Repository Root. This is only relevant for Monorepos. * is the Git Repository Root. This is only relevant for Monorepos.
* See https://vercel.com/blog/monorepos * See https://vercel.com/blog/monorepos
*/ */
repoRootPath?: string; repoRootPath: string;
/** /**
* An arbitrary object passed by the user in the build definition defined * An arbitrary object passed by the user in the build definition defined

View File

@@ -313,7 +313,7 @@ export default async function main(client: Client): Promise<number> {
// TODO: parallelize builds // TODO: parallelize builds
const buildResults: Map<Builder, BuildResult> = new Map(); const buildResults: Map<Builder, BuildResult> = new Map();
const overrides: PathOverride[] = []; const overrides: PathOverride[] = [];
const repoRootPath = cwd === workPath ? undefined : cwd; const repoRootPath = cwd;
const rootPackageJsonPath = repoRootPath || workPath; const rootPackageJsonPath = repoRootPath || workPath;
const corepackShimDir = await initCorepack({ cwd, rootPackageJsonPath }); const corepackShimDir = await initCorepack({ cwd, rootPackageJsonPath });

View File

@@ -142,6 +142,7 @@ export async function executeBuild(
files, files,
entrypoint, entrypoint,
workPath, workPath,
repoRootPath: workPath,
config, config,
meta: { meta: {
isDev: true, isDev: true,

View File

@@ -1735,6 +1735,7 @@ export default class DevServer {
entrypoint: match.entrypoint, entrypoint: match.entrypoint,
workPath, workPath,
config: match.config || {}, config: match.config || {},
repoRootPath: this.cwd,
meta: { meta: {
isDev: true, isDev: true,
requestPath, requestPath,

View File

@@ -39,7 +39,7 @@ export async function downloadFilesInWorkPath({
workPath, workPath,
files, files,
meta = {}, meta = {},
}: BuildOptions) { }: Pick<BuildOptions, 'entrypoint' | 'workPath' | 'files' | 'meta'>) {
debug('Downloading user files...'); debug('Downloading user files...');
let downloadedFiles = await download(files, workPath, meta); let downloadedFiles = await download(files, workPath, meta);
if (meta.isDev) { if (meta.isDev) {
@@ -67,7 +67,6 @@ export const build = async ({
files: originalFiles, files: originalFiles,
entrypoint, entrypoint,
meta, meta,
config,
}); });
try { try {

View File

@@ -20,6 +20,7 @@ describe('build()', () => {
files: {}, files: {},
entrypoint: 'package.json', entrypoint: 'package.json',
workPath, workPath,
repoRootPath: workPath,
config: {}, config: {},
}); });
assert('output' in result); assert('output' in result);
@@ -36,6 +37,7 @@ describe('build()', () => {
files: {}, files: {},
entrypoint: 'package.json', entrypoint: 'package.json',
workPath, workPath,
repoRootPath: workPath,
config: {}, config: {},
}); });
const cacheNames = Object.keys(cache); const cacheNames = Object.keys(cache);