Run example check in parallel with 5 at most (#7275)
This commit is contained in:
parent
96ae37eb09
commit
6721b1f699
3 changed files with 17 additions and 5 deletions
|
@ -5306,6 +5306,9 @@ importers:
|
||||||
kleur:
|
kleur:
|
||||||
specifier: ^4.1.4
|
specifier: ^4.1.4
|
||||||
version: 4.1.5
|
version: 4.1.5
|
||||||
|
p-limit:
|
||||||
|
specifier: ^4.0.0
|
||||||
|
version: 4.0.0
|
||||||
svelte:
|
svelte:
|
||||||
specifier: ^3.48.0
|
specifier: ^3.48.0
|
||||||
version: 3.58.0
|
version: 3.58.0
|
||||||
|
|
|
@ -13,14 +13,15 @@
|
||||||
"esbuild": "^0.17.12",
|
"esbuild": "^0.17.12",
|
||||||
"globby": "^12.2.0",
|
"globby": "^12.2.0",
|
||||||
"kleur": "^4.1.4",
|
"kleur": "^4.1.4",
|
||||||
|
"p-limit": "^4.0.0",
|
||||||
"svelte": "^3.48.0",
|
"svelte": "^3.48.0",
|
||||||
"tar": "^6.1.11"
|
"tar": "^6.1.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@octokit/action": "^3.18.1",
|
"@octokit/action": "^3.18.1",
|
||||||
"del": "^7.0.0",
|
"del": "^7.0.0",
|
||||||
"execa": "^6.1.0",
|
|
||||||
"esbuild-plugin-copy": "^2.0.2",
|
"esbuild-plugin-copy": "^2.0.2",
|
||||||
|
"execa": "^6.1.0",
|
||||||
"tsconfig-resolver": "^3.0.1"
|
"tsconfig-resolver": "^3.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import { readdirSync, readFileSync, writeFileSync } from 'fs';
|
import { readdirSync, readFileSync, writeFileSync } from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import pLimit from 'p-limit';
|
||||||
import { tsconfigResolverSync } from 'tsconfig-resolver';
|
import { tsconfigResolverSync } from 'tsconfig-resolver';
|
||||||
|
|
||||||
function checkExamples() {
|
function checkExamples() {
|
||||||
|
@ -11,9 +12,13 @@ function checkExamples() {
|
||||||
|
|
||||||
console.log(`Running astro check on ${examples.length} examples...`);
|
console.log(`Running astro check on ${examples.length} examples...`);
|
||||||
|
|
||||||
Promise.all(
|
// Run astro check in parallel with 5 at most
|
||||||
examples.map(
|
const checkPromises = [];
|
||||||
(example) =>
|
const limit = pLimit(5);
|
||||||
|
|
||||||
|
for (const example of examples) {
|
||||||
|
checkPromises.push(
|
||||||
|
limit(() =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
const originalConfig = prepareExample(example.name);
|
const originalConfig = prepareExample(example.name);
|
||||||
let data = '';
|
let data = '';
|
||||||
|
@ -37,7 +42,10 @@ function checkExamples() {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
).then((codes) => {
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Promise.all(checkPromises).then((codes) => {
|
||||||
if (codes.some((code) => code !== 0)) {
|
if (codes.some((code) => code !== 0)) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue