Skip to content

Commit 537ccbd

Browse files
Merge pull request #750 from pattern-lab/feature/749-default-config
Adding getDefaultConfig function to core
2 parents 8d0e031 + d892c4e commit 537ccbd

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

core/lib/patternlab.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const cleanHtml = require('js-beautify').html;
1818
const inherits = require('util').inherits;
1919
const pm = require('./plugin_manager');
2020
const packageInfo = require('../../package.json');
21+
const defaultConfig = require('../../patternlab-config.json');
2122
const dataLoader = require('./data_loader')();
2223
const logger = require('./log');
2324
const jsonCopy = require('./json_copy');
@@ -269,7 +270,6 @@ class PatternLab {
269270

270271

271272
// info methods
272-
273273
getVersion() {
274274
return this.package.version;
275275
}
@@ -422,6 +422,15 @@ function installPlugin(pluginName) {
422422
plugin_manager.install_plugin(pluginName);
423423
}
424424

425+
/**
426+
* Returns the standardized default config
427+
*
428+
* @return {object} Returns the object representation of the patternlab-config.json
429+
*/
430+
function getDefaultConfig() {
431+
return defaultConfig
432+
}
433+
425434
const patternlab_engine = function (config) {
426435
const patternlab = new PatternLab(config);
427436
const paths = patternlab.config.paths;
@@ -730,7 +739,7 @@ const patternlab_engine = function (config) {
730739
version: function () {
731740
return patternlab.logVersion();
732741
},
733-
742+
734743
/**
735744
* return current version
736745
*
@@ -869,5 +878,6 @@ const patternlab_engine = function (config) {
869878
patternlab_engine.build_pattern_data = buildPatternData;
870879
patternlab_engine.process_all_patterns_iterative = processAllPatternsIterative;
871880
patternlab_engine.process_all_patterns_recursive = processAllPatternsRecursive;
881+
patternlab_engine.getDefaultConfig = getDefaultConfig;
872882

873883
module.exports = patternlab_engine;

test/patternlab_tests.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const tap = require('tap');
44
const rewire = require("rewire");
55
const _ = require('lodash');
66
const fs = require('fs-extra');
7+
const defaultConfig = require('../patternlab-config.json');
78
var config = require('./util/patternlab-config.json');
89

910
var plEngineModule = rewire('../core/lib/patternlab');
@@ -81,3 +82,10 @@ tap.test('buildPatternData - can load json, yaml, and yml files', function(test)
8182
test.equals(dataResult.from_json, "from_json");
8283
test.end();
8384
});
85+
86+
tap.test('getDefaultConfig - should return the default config object', function(test) {
87+
const requestedConfig = plEngineModule.getDefaultConfig();
88+
test.type(requestedConfig, 'object');
89+
test.equals(requestedConfig, defaultConfig);
90+
test.end();
91+
});

0 commit comments

Comments
 (0)