summaryrefslogtreecommitdiff
path: root/scripts/smoke/check.js
diff options
context:
space:
mode:
authorGravatar Bjorn Lu <bjornlu.dev@gmail.com> 2023-06-02 21:14:44 +0800
committerGravatar GitHub <noreply@github.com> 2023-06-02 21:14:44 +0800
commit6721b1f699b457e83124489b7230cbbf5e8eb560 (patch)
tree318d75cab22b7b1d8b996f7fa9fd50f060e3412a /scripts/smoke/check.js
parent96ae37eb09f7406f40fba93e14b2a26ccd46640c (diff)
downloadastro-6721b1f699b457e83124489b7230cbbf5e8eb560.tar.gz
astro-6721b1f699b457e83124489b7230cbbf5e8eb560.tar.zst
astro-6721b1f699b457e83124489b7230cbbf5e8eb560.zip
Run example check in parallel with 5 at most (#7275)
Diffstat (limited to 'scripts/smoke/check.js')
-rw-r--r--scripts/smoke/check.js16
1 files changed, 12 insertions, 4 deletions
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);
}