Skip to content

Commit 8bf186b

Browse files
committed
fix(cli): pass watch options cleanly to core
1 parent 663d8e1 commit 8bf186b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

packages/cli/bin/cli-actions/serve.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const serve = options =>
77
wrapAsync(function*() {
88
const config = yield resolveConfig(options.parent.config);
99
servePatterns(config, options);
10-
servePatterns(config, options.watch);
1110
});
1211

1312
module.exports = serve;

packages/cli/bin/patternlab.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ cli
5757
.alias('compile')
5858
.description('Build Pattern Lab. Optionally (re-)build only the patterns')
5959
.option('-p, --patterns-only', 'Whether to only build patterns')
60+
.option('--no-watch', 'Start watching for changes')
6061
.action(build);
6162

6263
/**
@@ -130,7 +131,7 @@ cli
130131
.command('serve')
131132
.alias('browse')
132133
.description('Starts a server to inspect files in browser')
133-
.option('-w, --watch', 'Start watching for changes')
134+
.option('--no-watch', 'Start watching for changes')
134135
.action(serve);
135136

136137
// Show additional help

packages/cli/bin/serve.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ const { error, info } = require('./utils');
99
* @func serve
1010
* @desc Start a browser-sync server in the Pattern Lab public dir
1111
* @param {object} config - The passed Pattern Lab config
12+
* @param {object} options - The passed options at invocation time
1213
*/
13-
function serve(config) {
14+
function serve(config, options) {
1415
if (!isValidConfig) {
1516
throw new TypeError(
1617
'serve: Expects config not to be empty and of type object.'
@@ -37,7 +38,7 @@ function serve(config) {
3738
try {
3839
info(`serve: Serving your files …`);
3940
const pl = patternlab(config);
40-
pl.server.serve({});
41+
pl.server.serve(options);
4142
} catch (err) {
4243
error(err);
4344
}

packages/core/src/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,12 @@ const patternlab_module = function(config) {
266266
* @param {object} options an object used to control build behavior
267267
* @param {bool} options.cleanPublic whether or not to delete the configured output location (usually `public/`) before build
268268
* @param {object} options.data additional data to be merged with global data prior to build
269-
* @param {bool} options.watch **ALWAYS OVERRIDDEN to `true`** whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
269+
* @param {bool} [true] options.watch whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
270270
* @returns {Promise} a promise fulfilled when build is complete
271271
*/
272272
serve: options => {
273-
const _options = Object.assign({}, options, { watch: true });
274273
return _api
275-
.build(_options)
274+
.build(options)
276275
.then(() => server.serve())
277276
.catch(e =>
278277
logger.error(`error inside core index.js server serve: ${e}`)

0 commit comments

Comments
 (0)