diff --git a/packages/cli/bin/cli-actions/build.js b/packages/cli/bin/cli-actions/build.js
index d6cf99c51..c6a34434a 100644
--- a/packages/cli/bin/cli-actions/build.js
+++ b/packages/cli/bin/cli-actions/build.js
@@ -1,6 +1,5 @@
'use strict';
const buildPatterns = require('../build');
-const copyFiles = require('../copy-source-files');
const resolveConfig = require('../resolve-config');
const { error, info, wrapAsync } = require('../utils');
@@ -8,7 +7,6 @@ const build = options =>
wrapAsync(function*() {
try {
const config = yield resolveConfig(options.parent.config);
- yield copyFiles(config.paths);
yield buildPatterns(config, options);
info(`build: Yay, your Pattern Lab project was successfully built ☺`);
} catch (err) {
diff --git a/packages/cli/bin/cli-actions/serve.js b/packages/cli/bin/cli-actions/serve.js
index 2ee267194..6e2cc8fd2 100644
--- a/packages/cli/bin/cli-actions/serve.js
+++ b/packages/cli/bin/cli-actions/serve.js
@@ -1,14 +1,12 @@
'use strict';
const resolveConfig = require('../resolve-config');
-const build = require('./build');
const servePatterns = require('../serve');
const wrapAsync = require('../utils').wrapAsync;
const serve = options =>
wrapAsync(function*() {
const config = yield resolveConfig(options.parent.config);
- yield build(options);
- servePatterns(config, options.watch);
+ servePatterns(config, options);
});
module.exports = serve;
diff --git a/packages/cli/bin/copy-source-files.js b/packages/cli/bin/copy-source-files.js
deleted file mode 100644
index 509e17862..000000000
--- a/packages/cli/bin/copy-source-files.js
+++ /dev/null
@@ -1,27 +0,0 @@
-'use strict';
-const copy = require('./utils').copyWithPattern;
-const debug = require('./utils').debug;
-const wrapAsync = require('./utils').wrapAsync;
-
-/**
- * @func copyFilesFromSourceToPublic
- * @desc Copies files from the source path to the public path.
- * @param {object} paths - The passed Pattern Lab config paths member.
- * @return {Array}
- */
-const copyFilesFromSourceToPublic = paths =>
- wrapAsync(function*() {
- // Copy files over
- const copiedFiles = [
- copy(paths.source.styleguide, '*', paths.public.root),
- copy(paths.source.js, '**/*.js', paths.public.js),
- copy(paths.source.css, '*.css', paths.public.css),
- copy(paths.source.images, '*', paths.public.images),
- copy(paths.source.fonts, '*', paths.public.fonts),
- copy(paths.source.root, 'favicon.ico', paths.public.root),
- ];
- debug(`build: Your files were copied over to ${paths.public.root}`);
- return yield Promise.all(copiedFiles);
- });
-
-module.exports = copyFilesFromSourceToPublic;
diff --git a/packages/cli/bin/patternlab.js b/packages/cli/bin/patternlab.js
index 8800dd2fd..0e7eeed22 100755
--- a/packages/cli/bin/patternlab.js
+++ b/packages/cli/bin/patternlab.js
@@ -57,6 +57,7 @@ cli
.alias('compile')
.description('Build Pattern Lab. Optionally (re-)build only the patterns')
.option('-p, --patterns-only', 'Whether to only build patterns')
+ .option('--no-watch', 'Start watching for changes')
.action(build);
/**
@@ -130,7 +131,7 @@ cli
.command('serve')
.alias('browse')
.description('Starts a server to inspect files in browser')
- .option('-w, --watch', 'Start watching for changes')
+ .option('--no-watch', 'Start watching for changes')
.action(serve);
// Show additional help
diff --git a/packages/cli/bin/serve.js b/packages/cli/bin/serve.js
index e473a4390..a7502b65f 100644
--- a/packages/cli/bin/serve.js
+++ b/packages/cli/bin/serve.js
@@ -9,8 +9,9 @@ const { error, info } = require('./utils');
* @func serve
* @desc Start a browser-sync server in the Pattern Lab public dir
* @param {object} config - The passed Pattern Lab config
+ * @param {object} options - The passed options at invocation time
*/
-function serve(config) {
+function serve(config, options) {
if (!isValidConfig) {
throw new TypeError(
'serve: Expects config not to be empty and of type object.'
@@ -37,7 +38,7 @@ function serve(config) {
try {
info(`serve: Serving your files …`);
const pl = patternlab(config);
- pl.server.serve({});
+ pl.server.serve(options);
} catch (err) {
error(err);
}
diff --git a/packages/core/docs/README.md b/packages/core/docs/README.md
index 9eaf02714..7317083f6 100644
--- a/packages/core/docs/README.md
+++ b/packages/core/docs/README.md
@@ -63,12 +63,12 @@ Builds patterns, copies assets, and constructs user interface
**Emits**: event:PATTERNLAB_BUILD_START, event:PATTERNLAB_BUILD_END
**See**: [all events](./events.md)
-| Param | Type | Description |
-| --- | --- | --- |
-| options | object | an object used to control build behavior |
-| options.cleanPublic | bool | whether or not to delete the configured output location (usually `public/`) before build |
-| options.data | object | additional data to be merged with global data prior to build |
-| options.watch | bool | whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| options | object | | an object used to control build behavior |
+| [options.cleanPublic] | bool | true | whether or not to delete the configured output location (usually `public/`) before build |
+| [options.data] | object | {} | additional data to be merged with global data prior to build |
+| [options.watch] | bool | true | whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |
@@ -122,11 +122,11 @@ Builds patterns only, leaving existing user interface files intact
**Kind**: instance property of [patternlab](#patternlab)
**Returns**: Promise - a promise fulfilled when build is complete
-| Param | Type | Description |
-| --- | --- | --- |
-| options | object | an object used to control build behavior |
-| options.cleanPublic | bool | whether or not to delete the configured output location (usually `public/`) before build |
-| options.data | object | additional data to be merged with global data prior to build |
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| [options.cleanPublic] | bool | true | whether or not to delete the configured output location (usually `public/`) before build |
+| [options.data] | object | {} | additional data to be merged with global data prior to build |
+| [options.watch] | bool | true | whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |
@@ -162,12 +162,12 @@ Build patterns, copies assets, and constructs user interface. Watches configured
**Kind**: static method of [server](#patternlab.server)
**Returns**: Promise - a promise fulfilled when build is complete
-| Param | Type | Description |
-| --- | --- | --- |
-| options | object | an object used to control build behavior |
-| options.cleanPublic | bool | whether or not to delete the configured output location (usually `public/`) before build |
-| options.data | object | additional data to be merged with global data prior to build |
-| options.watch | bool | **ALWAYS OVERRIDDEN to `true`** whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| options | object | | an object used to control build behavior |
+| [options.cleanPublic] | bool | true | whether or not to delete the configured output location (usually `public/`) before build |
+| [options.data] | object | {} | additional data to be merged with global data prior to build |
+| [options.watch] | bool | true | whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |
diff --git a/packages/core/docs/events.md b/packages/core/docs/events.md
index 6b01e90d7..2df8191d1 100644
--- a/packages/core/docs/events.md
+++ b/packages/core/docs/events.md
@@ -5,7 +5,7 @@
Pattern Lab emits numerous events during the [build](../docs/) process. Some uses of events:
* Core uses `patternlab-pattern-change` events when watching for changes in order to trigger another build
-* Plugins such as [plugin-node-tab](https://github.com/pattern-lab/plugin-node-tab) can use an event like `patternlab-pattern-write-end` to define additional code tabs to the pattern viewer / modal
+* Plugins such as [plugin-tab](https://github.com/pattern-lab/patternlab-node/tree/master/packages/plugin-tab) can use an event like `patternlab-pattern-write-end` to define additional code tabs to the pattern viewer / modal
Learn more about [Creating Plugins](https://github.com/pattern-lab/patternlab-node/wiki/Creating-Plugins).
diff --git a/packages/core/src/index.js b/packages/core/src/index.js
index eb20f4af0..653a9f731 100644
--- a/packages/core/src/index.js
+++ b/packages/core/src/index.js
@@ -84,9 +84,9 @@ const patternlab_module = function(config) {
* @name build
* @instance
* @param {object} options an object used to control build behavior
- * @param {bool} options.cleanPublic whether or not to delete the configured output location (usually `public/`) before build
- * @param {object} options.data additional data to be merged with global data prior to build
- * @param {bool} options.watch whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
+ * @param {bool} [options.cleanPublic=true] whether or not to delete the configured output location (usually `public/`) before build
+ * @param {object} [options.data={}] additional data to be merged with global data prior to build
+ * @param {bool} [options.watch=true] whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
* @emits PATTERNLAB_BUILD_START
* @emits PATTERNLAB_BUILD_END
* @see {@link ./events.md|all events}
@@ -231,9 +231,9 @@ const patternlab_module = function(config) {
* @memberof patternlab
* @name patternsonly
* @instance
- * @param {object} options an object used to control build behavior
- * @param {bool} options.cleanPublic whether or not to delete the configured output location (usually `public/`) before build
- * @param {object} options.data additional data to be merged with global data prior to build
+ * @param {bool} [options.cleanPublic=true] whether or not to delete the configured output location (usually `public/`) before build
+ * @param {object} [options.data={}] additional data to be merged with global data prior to build
+ * @param {bool} [options.watch=true] whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
* @returns {Promise} a promise fulfilled when build is complete
*/
patternsonly: function(options) {
@@ -264,15 +264,14 @@ const patternlab_module = function(config) {
* @method serve
* @memberof patternlab.server
* @param {object} options an object used to control build behavior
- * @param {bool} options.cleanPublic whether or not to delete the configured output location (usually `public/`) before build
- * @param {object} options.data additional data to be merged with global data prior to build
- * @param {bool} options.watch **ALWAYS OVERRIDDEN to `true`** whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
+ * @param {bool} [options.cleanPublic=true] whether or not to delete the configured output location (usually `public/`) before build
+ * @param {object} [options.data={}] additional data to be merged with global data prior to build
+ * @param {bool} [options.watch=true] whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
* @returns {Promise} a promise fulfilled when build is complete
*/
serve: options => {
- const _options = Object.assign({}, options, { watch: true });
return _api
- .build(_options)
+ .build(options)
.then(() => server.serve())
.catch(e =>
logger.error(`error inside core index.js server serve: ${e}`)