Skip to content

Commit

Permalink
feat(roc-plugin-repo): Added new watch command that can be used over -w
Browse files Browse the repository at this point in the history
This is useful when implementing custom a build commands and want to be able to do the same when running watch.
  • Loading branch information
dlmr committed Jan 16, 2018
1 parent a46ba03 commit 86c5cf8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions extensions/roc-plugin-repo/src/actions/runScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ export default ({ context }) => (script, projects, extra) => () => {
return lazyRequire('./publish')(context, projects, extra);
} else if (script === 'test') {
return lazyRequire('./test')(context, projects, extra);
} else if (script === 'watch') {
return lazyRequire('./build')(context, projects, {
...extra,
options: {
watch: true,
},
});
}

return [];
Expand Down
14 changes: 14 additions & 0 deletions extensions/roc-plugin-repo/src/commands/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import scriptRunner from './utils/scriptRunner';

export default projects => ({
arguments: { managed: { projects: selectedProjects } },
options: { managed: { concurrent } },
context,
}) => {
const settings = context.config.settings.repo;
const selected = projects.filter(
({ name }) => !selectedProjects || selectedProjects.includes(name),
);

return scriptRunner('watch')(selected, settings, concurrent);
};
21 changes: 21 additions & 0 deletions extensions/roc-plugin-repo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,27 @@ module.exports.roc = {
},
options: jestOptions,
},
watch: {
command: args => fetchProjects(lazyRequire('./commands/watch'))(args),
description: 'Build projects in watch mode',
settings: true,
arguments: {
projects: {
validator: validators.isArray(validators.isString),
description: 'Projects to use',
},
},
options: {
concurrent: {
validator: validators.oneOf(
validators.isBoolean,
validators.isInteger,
),
description: 'Run concurrently',
default: 2,
},
},
},
},
},
};

0 comments on commit 86c5cf8

Please sign in to comment.