Skip to content

Commit d2f346d

Browse files
committed
feat(patternlabjs): Remove build callback
closes #751
1 parent 50474de commit d2f346d

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

core/lib/patternlab.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,10 @@ const patternlab_engine = function (config) {
752752
/**
753753
* build patterns, copy assets, and construct ui
754754
*
755-
* @param {function} callback a function invoked when build is complete
756755
* @param {object} options an object used to control build behavior
757756
* @returns {Promise} a promise fulfilled when build is complete
758757
*/
759-
build: function (callback, options) {
758+
build: function (options) {
760759
if (patternlab && patternlab.isBusy) {
761760
logger.info('Pattern Lab is busy building a previous run - returning early.');
762761
return Promise.resolve();
@@ -770,21 +769,20 @@ const patternlab_engine = function (config) {
770769
this.events.on('patternlab-pattern-change', () => {
771770
if (!patternlab.isBusy) {
772771
options.cleanPublic = false;
773-
return this.build(callback, options);
772+
return this.build(options);
774773
}
775774
return Promise.resolve();
776775
});
777776

778777
this.events.on('patternlab-global-change', () => {
779778
if (!patternlab.isBusy) {
780779
options.cleanPublic = true; //rebuild everything
781-
return this.build(callback, options);
780+
return this.build(options);
782781
}
783782
return Promise.resolve();
784783
});
785784

786785
patternlab.isBusy = false;
787-
callback();
788786
});
789787
},
790788

@@ -800,19 +798,17 @@ const patternlab_engine = function (config) {
800798
/**
801799
* build patterns only, leaving existing public files intact
802800
*
803-
* @param {function} callback a function invoked when build is complete
804801
* @param {object} options an object used to control build behavior
805802
* @returns {Promise} a promise fulfilled when build is complete
806803
*/
807-
patternsonly: function (callback, options) {
804+
patternsonly: function (options) {
808805
if (patternlab && patternlab.isBusy) {
809806
logger.info('Pattern Lab is busy building a previous run - returning early.');
810807
return Promise.resolve();
811808
}
812809
patternlab.isBusy = true;
813810
return buildPatterns(options.cleanPublic).then(() => {
814811
patternlab.isBusy = false;
815-
callback();
816812
});
817813
},
818814

@@ -864,7 +860,7 @@ const patternlab_engine = function (config) {
864860
*/
865861
serve: function (options) {
866862
options.watch = true;
867-
return this.build(() => {}, options).then(function () {
863+
return this.build(options).then(function () {
868864
serve(patternlab);
869865
});
870866
},

package-lock.json

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"version": "3.0.0-alpha.4",
55
"main": "./core/lib/patternlab.js",
66
"dependencies": {
7+
"@pattern-lab/live-server": "^1.3.2",
8+
"@pattern-lab/patternengine-node-mustache": "^2.0.0-alpha.1",
79
"async": "^2.1.2",
810
"chalk": "^1.1.3",
911
"chokidar": "^1.7.0",
@@ -15,7 +17,6 @@
1517
"graphlib": "^2.1.1",
1618
"js-beautify": "^1.6.3",
1719
"js-yaml": "^3.6.1",
18-
"@pattern-lab/live-server": "^1.3.2",
1920
"lodash": "~4.13.1",
2021
"markdown-it": "^6.0.1",
2122
"node-fetch": "^1.6.0",

test/patternlab_tests.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ tap.test('buildPatterns - should replace data link even when pattern parameter p
6868
var pl = new plEngineModule(config);
6969

7070
//act
71-
pl.build(function() {
71+
pl.build(true).then(() => {
7272
test.end();
73-
}, true);
73+
});
7474
});
7575

7676
tap.test('buildPatternData - can load json, yaml, and yml files', function(test) {

0 commit comments

Comments
 (0)