mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-07 12:57:47 +00:00
[static-build] Fix error handling for unexpected output directory (#4727)
This PR improves the error handling when a zero config framework has an unexpected output directory. Previously, setting a Docusaurus 2.0 build command to `docusaurus build && mv build foo` would fail with the following: ``` Error: ENOENT: no such file or directory, scandir '/vercel/514ce14b/build' ``` With this PR, the error message will show the expected: ``` Error: No Output Directory named "build" found after the Build completed. You can configure the Output Directory in your project settings. Learn more: https://vercel.com/docs/v2/platform/frequently-asked-questions#missing-public-directory ``` I also changed the usage of [`promisify(fs)`](https://nodejs.org/docs/latest-v10.x/api/util.html#util_util_promisify_original) to [`fs.promises`](https://nodejs.org/docs/latest-v10.x/api/fs.html#fs_fs_promises_api) which is available in Node 10 or newer. Lastly, I updated the test suite to check if the correct error message is returned for builds we expect to fail.
This commit is contained in:
@@ -59,10 +59,18 @@ async function nowDeploy(bodies, randomness) {
|
||||
console.log('deploymentUrl', `https://${deploymentUrl}`);
|
||||
|
||||
for (let i = 0; i < 750; i += 1) {
|
||||
const { state } = await deploymentGet(deploymentId);
|
||||
if (state === 'ERROR')
|
||||
throw new Error(`State of ${deploymentUrl} is ${state}`);
|
||||
if (state === 'READY') break;
|
||||
const deployment = await deploymentGet(deploymentId);
|
||||
const { readyState } = deployment;
|
||||
if (readyState === 'ERROR') {
|
||||
const error = new Error(
|
||||
`State of https://${deploymentUrl} is ${readyState}`
|
||||
);
|
||||
error.deployment = deployment;
|
||||
throw error;
|
||||
}
|
||||
if (readyState === 'READY') {
|
||||
break;
|
||||
}
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
}
|
||||
|
||||
@@ -123,7 +131,7 @@ async function deploymentPost(payload) {
|
||||
}
|
||||
|
||||
async function deploymentGet(deploymentId) {
|
||||
const url = `/v3/now/deployments/${deploymentId}`;
|
||||
const url = `/v12/now/deployments/${deploymentId}`;
|
||||
const resp = await fetchWithAuth(url);
|
||||
const json = await resp.json();
|
||||
if (json.error) {
|
||||
|
||||
Reference in New Issue
Block a user