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