mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 12:57:46 +00:00
[now-build-utils][now-node] Throw new NowBuildError() (#3496)
This PR does the following - Add and export class, `NowBuildError`, that can be thrown to stop the build and print an error but it will not print a stack trace. - Improve logic for discontinued node versions and add more tests - Remove hack (#3425) for undefined TERM, fixed by updating dependencies - Rename `silent` variable to `isAuto` which means the node version was automatically selected, not defined in `package.json` - Rename `test` deployments to `test2020` so that a fresh project is created with latest Node.js 12.x
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
const assert = require('assert');
|
||||
const { createHash } = require('crypto');
|
||||
const { homedir } = require('os');
|
||||
const path = require('path');
|
||||
const fetch = require('./fetch-retry.js');
|
||||
|
||||
@@ -28,7 +27,7 @@ async function nowDeploy (bodies, randomness) {
|
||||
RANDOMNESS_BUILD_ENV_VAR: randomness,
|
||||
},
|
||||
},
|
||||
name: 'test',
|
||||
name: 'test2020',
|
||||
files,
|
||||
builds: nowJson.builds,
|
||||
routes: nowJson.routes || [],
|
||||
@@ -133,20 +132,12 @@ async function fetchWithAuth (url, opts = {}) {
|
||||
if (!opts.headers) opts.headers = {};
|
||||
|
||||
if (!opts.headers.Authorization) {
|
||||
const { NOW_TOKEN, CIRCLECI } = process.env;
|
||||
currentCount += 1;
|
||||
if (!token || currentCount === MAX_COUNT) {
|
||||
currentCount = 0;
|
||||
if (NOW_TOKEN) {
|
||||
token = NOW_TOKEN;
|
||||
} else if (CIRCLECI) {
|
||||
token = await fetchTokenWithRetry(
|
||||
Buffer.from(str, 'base64').toString()
|
||||
);
|
||||
} else {
|
||||
const authJsonPath = path.join(homedir(), '.now/auth.json');
|
||||
token = require(authJsonPath).token;
|
||||
}
|
||||
token = await fetchTokenWithRetry(
|
||||
Buffer.from(str, 'base64').toString()
|
||||
);
|
||||
}
|
||||
|
||||
opts.headers.Authorization = `Bearer ${token}`;
|
||||
|
||||
Reference in New Issue
Block a user