Skip to content

Commit

Permalink
Merge pull request #10808 from storybookjs/chore/build-package-improv…
Browse files Browse the repository at this point in the history
…ements

Scripts: parallel execution on build package scripts
  • Loading branch information
shilman authored May 17, 2020
2 parents 123476b + 8b17bae commit 1e37270
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions scripts/build-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,23 @@ function run() {
.map((key) => key.suffix)
.filter(Boolean);

const glob =
let glob =
packageNames.length > 1
? `@storybook/{${packageNames.join(',')}}`
: `@storybook/${packageNames[0]}`;

const isAllPackages = process.argv.includes('--all');
if (isAllPackages) {
glob = '@storybook/*';

log.warn(
'You are building a lot of packages on watch mode. This is an expensive action and might slow your computer down.\nIf this is an issue, run yarn build to filter packages and speed things up!'
);
}

if (watchMode) {
const runWatchMode = () => {
const baseWatchCommand = `lerna exec --scope "${glob}" -- cross-env-shell node ${resolve(
const baseWatchCommand = `lerna exec --scope '${glob}' --parallel -- cross-env-shell node ${resolve(
__dirname
)}`;
const watchTsc = `${baseWatchCommand}/watch-tsc.js`;
Expand All @@ -152,24 +161,7 @@ function run() {
spawn(command);
};

if (packageNames.length < 5) {
runWatchMode();
} else {
inquirer
.prompt([
{
type: 'confirm',
message:
'You selected a lot of packages on watch mode. This is a very expensive action and might slow your computer down. Do you want to continue?',
name: 'confirmation',
},
])
.then(({ confirmation }) => {
if (confirmation === true) {
runWatchMode();
}
});
}
runWatchMode();
} else {
spawn(`lerna run prepare --scope "${glob}"`);
}
Expand Down

0 comments on commit 1e37270

Please sign in to comment.