mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 12:57:46 +00:00
[build-utils][cli] Add env vars for VERCEL_PROJECT_SETTINGS_ (#9332)
This PR adds a few new environment variables for project settings. This allows frameworks targeting the [Build Output API](https://vercel.com/docs/build-output-api/v3) to read data that is normally only available in through the `config` object when developing a [Builder/Runtime](https://github.com/vercel/vercel/blob/main/DEVELOPING_A_RUNTIME.md). This will also solve the problem of old Builders/Runtimes that never passed the `config` through to `getNodeVersion()`. - Related to https://github.com/unjs/nitro/pull/879
This commit is contained in:
@@ -1025,6 +1025,27 @@ describe('build', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should set VERCEL_PROJECT_SETTINGS_ environment variables', async () => {
|
||||
const cwd = fixture('project-settings-env-vars');
|
||||
const output = join(cwd, '.vercel/output');
|
||||
try {
|
||||
process.chdir(cwd);
|
||||
const exitCode = await build(client);
|
||||
expect(exitCode).toEqual(0);
|
||||
|
||||
const contents = await fs.readJSON(join(output, 'static/env.json'));
|
||||
expect(contents).toMatchObject({
|
||||
VERCEL_PROJECT_SETTINGS_BUILD_COMMAND: `node build.cjs`,
|
||||
VERCEL_PROJECT_SETTINGS_INSTALL_COMMAND: '',
|
||||
VERCEL_PROJECT_SETTINGS_OUTPUT_DIRECTORY: 'out',
|
||||
VERCEL_PROJECT_SETTINGS_NODE_VERSION: '18.x',
|
||||
});
|
||||
} finally {
|
||||
process.chdir(originalCwd);
|
||||
delete process.env.__VERCEL_BUILD_RUNNING;
|
||||
}
|
||||
});
|
||||
|
||||
it('should apply "images" configuration from `vercel.json`', async () => {
|
||||
const cwd = fixture('images');
|
||||
const output = join(cwd, '.vercel/output');
|
||||
|
||||
Reference in New Issue
Block a user