fixed issue where install script errors were not properly propagated

Summary:
Our post install scripts didn't propagate installation errors in CI (or locally), leading to problems only appearing later in time, causing a lot of lost time {emoji:1f605}

Also moved printing what package is installing to _before_ running the script, so that you have actual useful info in case it fails.

Compilation errors of pkg and doctor were printed in our CI, but never threw exceptions.

Fixed the cause of those compilation errors as well using `skipLibCheck` like done in the root tsconfig

Reviewed By: jknoxville

Differential Revision: D20470985

fbshipit-source-id: 1b13d4d2c096f253cc9c1f0aac06982fc4aedf55
This commit is contained in:
Michel Weststrate
2020-03-16 16:49:21 -07:00
committed by Facebook GitHub Bot
parent f83a088f0d
commit f919a0d1a3
3 changed files with 11 additions and 5 deletions

View File

@@ -5,7 +5,8 @@
"module": "commonjs", "module": "commonjs",
"declaration": true, "declaration": true,
"outDir": "./lib", "outDir": "./lib",
"strict": true "strict": true,
"skipLibCheck": true
}, },
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"] "exclude": ["node_modules", "**/__tests__/*"]

View File

@@ -8,6 +8,7 @@
"strict": true, "strict": true,
"importHelpers": true, "importHelpers": true,
"esModuleInterop": true, "esModuleInterop": true,
"skipLibCheck": true,
"allowJs": true "allowJs": true
}, },
"include": [ "include": [

View File

@@ -39,7 +39,9 @@ Promise.all(
`Installing dependencies for ${flattenPackages.length} plugins`, `Installing dependencies for ${flattenPackages.length} plugins`,
); );
for (const pkg of flattenPackages) { for (const pkg of flattenPackages) {
const {stderr} = await exec( console.log(`Installing dependencies for ${pkg}...`);
// @ts-ignore
const {stderr, error} = await exec(
// This script is itself executed by yarn (as postinstall script), // This script is itself executed by yarn (as postinstall script),
// therefore another yarn instance is running, while we are trying to // therefore another yarn instance is running, while we are trying to
// install the plugin dependencies. We are setting a different port // install the plugin dependencies. We are setting a different port
@@ -52,16 +54,18 @@ Promise.all(
}, },
); );
if (stderr) { if (stderr) {
if (error && error.code !== 0) {
console.warn(`❌ Installing dependencies for ${pkg} failed`);
throw stderr;
}
console.warn(stderr); console.warn(stderr);
} else {
console.log(`Installed dependencies for ${pkg}`);
} }
} }
}) })
// eslint-disable-next-line // eslint-disable-next-line
.then(() => console.log('📦 Installed all plugin dependencies!')) .then(() => console.log('📦 Installed all plugin dependencies!'))
.catch(err => { .catch(err => {
console.error('❌ Installing plugin dependencies failed.');
console.error(err); console.error(err);
console.error('❌ Installing plugin dependencies failed.');
process.exit(1); process.exit(1);
}); });