1
0
mirror of synced 2025-12-22 03:16:52 -05:00

refactor unnecessary use of process.exit(1) (#21974)

This commit is contained in:
Peter Bengtsson
2021-10-18 10:43:32 -04:00
committed by GitHub
parent 53b41bd0ba
commit 26e5ee8425

View File

@@ -22,8 +22,7 @@ const dataFilenames = JSON.parse(
// check for required PAT // check for required PAT
if (!process.env.GITHUB_TOKEN) { if (!process.env.GITHUB_TOKEN) {
console.error('Error! You must have a GITHUB_TOKEN set in an .env file to run this script.') throw new Error('Error! You must have a GITHUB_TOKEN set in an .env file to run this script.')
process.exit(1)
} }
const versionsToBuild = Object.keys(allVersions) const versionsToBuild = Object.keys(allVersions)
@@ -33,13 +32,12 @@ const currentLanguage = 'en'
main() main()
async function main() { async function main() {
try {
const previewsJson = {} const previewsJson = {}
const upcomingChangesJson = {} const upcomingChangesJson = {}
const prerenderedObjects = {} const prerenderedObjects = {}
const prerenderedInputObjects = {} const prerenderedInputObjects = {}
const siteData = await loadData() const siteData = loadData()
// create a bare minimum context for rendering the graphql-object.html layout // create a bare minimum context for rendering the graphql-object.html layout
const context = { const context = {
@@ -56,9 +54,7 @@ async function main() {
// 1. UPDATE PREVIEWS // 1. UPDATE PREVIEWS
const previewsPath = getDataFilepath('previews', graphqlVersion) const previewsPath = getDataFilepath('previews', graphqlVersion)
const safeForPublicPreviews = yaml.load( const safeForPublicPreviews = yaml.load(await getRemoteRawContent(previewsPath, graphqlVersion))
await getRemoteRawContent(previewsPath, graphqlVersion)
)
await updateFile(previewsPath, yaml.dump(safeForPublicPreviews)) await updateFile(previewsPath, yaml.dump(safeForPublicPreviews))
previewsJson[graphqlVersion] = processPreviews(safeForPublicPreviews) previewsJson[graphqlVersion] = processPreviews(safeForPublicPreviews)
@@ -113,10 +109,7 @@ async function main() {
} }
await updateStaticFile(previewsJson, path.join(graphqlStaticDir, 'previews.json')) await updateStaticFile(previewsJson, path.join(graphqlStaticDir, 'previews.json'))
await updateStaticFile( await updateStaticFile(upcomingChangesJson, path.join(graphqlStaticDir, 'upcoming-changes.json'))
upcomingChangesJson,
path.join(graphqlStaticDir, 'upcoming-changes.json')
)
await updateStaticFile( await updateStaticFile(
prerenderedObjects, prerenderedObjects,
path.join(graphqlStaticDir, 'prerendered-objects.json') path.join(graphqlStaticDir, 'prerendered-objects.json')
@@ -128,10 +121,6 @@ async function main() {
// Ensure the YAML linter runs before checkinging in files // Ensure the YAML linter runs before checkinging in files
execSync('npx prettier -w "**/*.{yml,yaml}"') execSync('npx prettier -w "**/*.{yml,yaml}"')
} catch (e) {
console.error(e)
process.exit(1)
}
} }
// get latest from github/github // get latest from github/github