Set exit code to 1 if script failed

Summary: Fixed scripts to return exit code 1 in case of error.

Reviewed By: passy

Differential Revision: D22357664

fbshipit-source-id: 1e067fe507e8f33cf21e70f3d15fd97175b9544e
This commit is contained in:
Anton Nikolaev
2020-07-02 10:19:07 -07:00
committed by Facebook GitHub Bot
parent 70b87b70c7
commit a8a16e24b3
3 changed files with 22 additions and 11 deletions

View File

@@ -235,9 +235,9 @@
"build:dev": "cross-env NODE_ENV=development ./ts-node scripts/build-release.ts $@", "build:dev": "cross-env NODE_ENV=development ./ts-node scripts/build-release.ts $@",
"prebuild-headless": "yarn build:pkg", "prebuild-headless": "yarn build:pkg",
"build-headless": "cross-env NODE_ENV=production ./ts-node scripts/build-headless.ts $@", "build-headless": "cross-env NODE_ENV=production ./ts-node scripts/build-headless.ts $@",
"prebuild-plugin": "yarn build:pkg",
"build-plugin": "./ts-node scripts/build-plugin.ts", "build-plugin": "./ts-node scripts/build-plugin.ts",
"resolve-plugin-dir": "./ts-node scripts/resolve-plugin-dir.ts", "resolve-plugin-dir": "./ts-node scripts/resolve-plugin-dir.ts",
"list-plugins": "./ts-node scripts/list-plugins.ts",
"open-dist": "open ../dist/mac/Flipper.app --args --launcher=false --inspect=9229", "open-dist": "open ../dist/mac/Flipper.app --args --launcher=false --inspect=9229",
"fix": "eslint . --fix --ext .js,.ts,.tsx", "fix": "eslint . --fix --ext .js,.ts,.tsx",
"pretest": "yarn build:pkg", "pretest": "yarn build:pkg",
@@ -253,7 +253,6 @@
"lint": "yarn lint:eslint && yarn lint:flow && yarn lint:tsc", "lint": "yarn lint:eslint && yarn lint:flow && yarn lint:tsc",
"bump-versions": "./ts-node scripts/bump-versions.ts", "bump-versions": "./ts-node scripts/bump-versions.ts",
"publish-packages": "./ts-node scripts/publish-packages.ts", "publish-packages": "./ts-node scripts/publish-packages.ts",
"list-plugins": "./ts-node scripts/list-plugins.ts",
"everything": "yarn reset && yarn install && yarn lint && yarn test && yarn test-electron && yarn build --mac --mac-dmg --win --linux --linux-deb && yarn build-headless --mac --linux && yarn start" "everything": "yarn reset && yarn install && yarn lint && yarn test && yarn test-electron && yarn build --mac --mac-dmg --win --linux --linux-deb && yarn build-headless --mac --linux && yarn start"
}, },
"optionalDependencies": { "optionalDependencies": {

View File

@@ -13,10 +13,10 @@ import fs from 'fs-extra';
import {execSync} from 'child_process'; import {execSync} from 'child_process';
import {resolvePluginDir} from './workspaces'; import {resolvePluginDir} from './workspaces';
(async function buildPlugin() { async function buildPlugin(argv: string[]) {
const pluginName = process.argv[2]; const pluginName = argv[2];
const pluginDir = await resolvePluginDir(pluginName); const pluginDir = await resolvePluginDir(pluginName);
const outputFileArg = process.argv.length > 3 ? process.argv[3] : null; const outputFileArg = argv.length > 3 ? argv[3] : null;
const outputFile = outputFileArg const outputFile = outputFileArg
? path.resolve(outputFileArg) ? path.resolve(outputFileArg)
: path.join( : path.join(
@@ -30,4 +30,13 @@ import {resolvePluginDir} from './workspaces';
const packCmd = `yarn pack --cwd "${pluginDir}" --filename ${outputFile}`; const packCmd = `yarn pack --cwd "${pluginDir}" --filename ${outputFile}`;
execSync(bundleCmd, {cwd: rootDir, stdio: 'inherit'}); execSync(bundleCmd, {cwd: rootDir, stdio: 'inherit'});
execSync(packCmd, {cwd: rootDir, stdio: 'inherit'}); execSync(packCmd, {cwd: rootDir, stdio: 'inherit'});
})(); }
buildPlugin(process.argv)
.then(() => {
process.exit(0);
})
.catch((err: any) => {
console.error(err);
process.exit(1);
});

View File

@@ -9,8 +9,11 @@
import {resolvePluginDir} from './workspaces'; import {resolvePluginDir} from './workspaces';
(async function () { resolvePluginDir(process.argv[2])
const pluginName = process.argv[2]; .then((dir) => {
const pluginDir = await resolvePluginDir(pluginName); console.log(dir);
console.log(pluginDir); })
})(); .catch((err: any) => {
console.error(err);
process.exit(1);
});