Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts: parallel execution on build package scripts #10808

Merged
merged 2 commits into from
May 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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