Skip to content

Commit

Permalink
Fix update script (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Mar 5, 2024
1 parent ca7c300 commit d8fb3e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
16 changes: 1 addition & 15 deletions scripts/get-builtin-globals.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ const getText = async url => {
return text;
};

const any = async asyncFunctions => {
const errors = [];
for (const function_ of asyncFunctions) {
try {
// eslint-disable-next-line no-await-in-loop
return await function_();
} catch (error) {
errors.push(error);
}
}

throw new AggregateError(errors, 'All failed.');
};

const getSpecification = async () => {
let stat;

Expand All @@ -54,7 +40,7 @@ const getSpecification = async () => {
await fs.rm(CACHE_FILE);
}

const text = await any(SPECIFICATION_URLS.map(url => () => getText(url)));
const text = await Promise.any(SPECIFICATION_URLS.map(url => getText(url)));

await fs.mkdir(new URL('./', CACHE_FILE), {recursive: true});
await fs.writeFile(CACHE_FILE, text);
Expand Down
5 changes: 3 additions & 2 deletions scripts/update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ALL_JOBS = [
{
environment: 'builtin',
getGlobals: getBuiltinGlobals,
incremental: false,
},
{
environment: 'nodeBuiltin',
Expand Down Expand Up @@ -42,7 +43,7 @@ async function run(options) {
? ALL_JOBS.filter(job => job.environment === options.environment)
: ALL_JOBS;

for (const {environment, getGlobals, incremental = false} of jobs) {
for (const {environment, getGlobals, incremental = true} of jobs) {
const {
added,
removed,
Expand All @@ -52,7 +53,7 @@ async function run(options) {
environment,
getGlobals,
dryRun: options.dry,
incremental: incremental ?? !options.clean,
incremental: options.clean ? false : incremental,
});

console.log(`✅ ${environment} globals updated.`);
Expand Down

0 comments on commit d8fb3e2

Please sign in to comment.