0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

chore: fix issue in the check.js script (#7965)

This commit is contained in:
Emanuele Stoppa 2023-08-04 16:53:54 +01:00 committed by GitHub
parent 8ea6b6dedf
commit 0fd6dc7ec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,31 +18,32 @@ function checkExamples() {
for (const example of examples) { for (const example of examples) {
checkPromises.push( checkPromises.push(
limit(() => limit(
new Promise((resolve) => { () =>
const originalConfig = prepareExample(example.name); new Promise((resolve) => {
let data = ''; const originalConfig = prepareExample(example.name);
const child = spawn('node', ['../../packages/astro/astro.js', 'check'], { let data = '';
cwd: path.join('./examples', example.name), const child = spawn('node', ['../../packages/astro/astro.js', 'check'], {
env: { ...process.env, FORCE_COLOR: 'true' }, cwd: path.join('./examples', example.name),
}); env: { ...process.env, FORCE_COLOR: 'true' },
});
child.stdout.on('data', function (buffer) { child.stdout.on('data', function (buffer) {
data += buffer.toString(); data += buffer.toString();
}); });
child.on('exit', (code) => { child.on('exit', (code) => {
if (code !== 0) { if (code !== 0) {
console.error(data); console.error(data);
} }
if (originalConfig) { if (originalConfig) {
resetExample(example.name, originalConfig); resetExample(example.name, originalConfig);
} }
resolve(code); resolve(code);
}); });
}) })
) )
) );
} }
Promise.all(checkPromises).then((codes) => { Promise.all(checkPromises).then((codes) => {
@ -50,7 +51,7 @@ function checkExamples() {
process.exit(1); process.exit(1);
} }
console.log("No errors found!"); console.log('No errors found!');
}); });
} }
@ -75,7 +76,9 @@ function prepareExample(examplePath) {
}); });
} }
writeFileSync(tsconfigPath, JSON.stringify(tsconfig.config)); if (tsconfig.config) {
writeFileSync(tsconfigPath, JSON.stringify(tsconfig.config));
}
return originalConfig; return originalConfig;
} }