Skip to content

Commit

Permalink
configure run jobs to run in watch mode on build --watch (#1091)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Sep 26, 2020
1 parent 712f6f6 commit 884e4ab
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions snowpack/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class FileBuilder {

export async function command(commandOptions: CommandOptions) {
const {cwd, config} = commandOptions;
const isWatch = !!config.buildOptions.watch;

const buildDirectoryLoc = config.devOptions.out;
const internalFilesBuildLoc = path.join(buildDirectoryLoc, config.buildOptions.metaDir);
Expand All @@ -289,10 +290,10 @@ export async function command(commandOptions: CommandOptions) {

for (const runPlugin of config.plugins) {
if (runPlugin.run) {
await runPlugin
const runJob = runPlugin
.run({
isDev: false,
isHmrEnabled: false,
isDev: isWatch,
isHmrEnabled: getIsHmrEnabled(config),
// @ts-ignore: internal API only
log: (msg, data: {msg: string} = {}) => {
if (msg === 'WORKER_MSG') {
Expand All @@ -302,8 +303,14 @@ export async function command(commandOptions: CommandOptions) {
})
.catch((err) => {
logger.error(err.toString(), {name: runPlugin.name});
process.exit(1);
if (!isWatch) {
process.exit(1);
}
});
// Wait for the job to complete before continuing (unless in watch mode)
if (!isWatch) {
await runJob;
}
}
}

Expand Down

1 comment on commit 884e4ab

@vercel
Copy link

@vercel vercel bot commented on 884e4ab Sep 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aliasing was ignored due to a new commit existing for this branch, which will be aliased instead.

Please sign in to comment.