diff options
author | 2023-06-02 21:14:44 +0800 | |
---|---|---|
committer | 2023-06-02 21:14:44 +0800 | |
commit | 6721b1f699b457e83124489b7230cbbf5e8eb560 (patch) | |
tree | 318d75cab22b7b1d8b996f7fa9fd50f060e3412a | |
parent | 96ae37eb09f7406f40fba93e14b2a26ccd46640c (diff) | |
download | astro-6721b1f699b457e83124489b7230cbbf5e8eb560.tar.gz astro-6721b1f699b457e83124489b7230cbbf5e8eb560.tar.zst astro-6721b1f699b457e83124489b7230cbbf5e8eb560.zip |
Run example check in parallel with 5 at most (#7275)
-rw-r--r-- | pnpm-lock.yaml | 3 | ||||
-rw-r--r-- | scripts/package.json | 3 | ||||
-rw-r--r-- | scripts/smoke/check.js | 16 |
3 files changed, 17 insertions, 5 deletions
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dab25439a..27042e66b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5306,6 +5306,9 @@ importers: kleur: specifier: ^4.1.4 version: 4.1.5 + p-limit: + specifier: ^4.0.0 + version: 4.0.0 svelte: specifier: ^3.48.0 version: 3.58.0 diff --git a/scripts/package.json b/scripts/package.json index 47f65d972..5322af168 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -13,14 +13,15 @@ "esbuild": "^0.17.12", "globby": "^12.2.0", "kleur": "^4.1.4", + "p-limit": "^4.0.0", "svelte": "^3.48.0", "tar": "^6.1.11" }, "devDependencies": { "@octokit/action": "^3.18.1", "del": "^7.0.0", - "execa": "^6.1.0", "esbuild-plugin-copy": "^2.0.2", + "execa": "^6.1.0", "tsconfig-resolver": "^3.0.1" } } diff --git a/scripts/smoke/check.js b/scripts/smoke/check.js index 447a76edc..aa36a8a5f 100644 --- a/scripts/smoke/check.js +++ b/scripts/smoke/check.js @@ -3,6 +3,7 @@ import { spawn } from 'child_process'; import { readdirSync, readFileSync, writeFileSync } from 'fs'; import * as path from 'path'; +import pLimit from 'p-limit'; import { tsconfigResolverSync } from 'tsconfig-resolver'; function checkExamples() { @@ -11,9 +12,13 @@ function checkExamples() { console.log(`Running astro check on ${examples.length} examples...`); - Promise.all( - examples.map( - (example) => + // Run astro check in parallel with 5 at most + const checkPromises = []; + const limit = pLimit(5); + + for (const example of examples) { + checkPromises.push( + limit(() => new Promise((resolve) => { const originalConfig = prepareExample(example.name); let data = ''; @@ -36,8 +41,11 @@ function checkExamples() { resolve(code); }); }) + ) ) - ).then((codes) => { + } + + Promise.all(checkPromises).then((codes) => { if (codes.some((code) => code !== 0)) { process.exit(1); } |