-
Notifications
You must be signed in to change notification settings - Fork 405
Public API
Brian Muenzenmeyer edited this page Oct 12, 2017
·
11 revisions
// instantiation. assumed first step for below
const config = require('./patternlab-config.json');
const patternlab = require('patternlab-node')(config);
// print help
patternlab.help();
// build patterns, view all patterns, front end
patternlab.build(callback, deletePatternDir);
// build patterns only
patternlab.patternsonly(callback, deletePatternDir);
// log version to console
patternlab.version(); // v3.0.0
// return package.json version as string
patternlab.v(); // v3.0.0
// log available starterkits
// https://api.github.com/search/repositories?q=starterkit+in:name+user:pattern-lab&sort=stars&order=desc
patternlab.liststarterkits(); // [{"name": "starterkit-mustache-demo", "url": "https://github.com/pattern-lab/starterkit-mustache-demo" }, ..]
// load starterkit already available via `node_modules/`
patternlab.loadstarterkit(starterkitname, clean); // void
// install plugin already available via `node_modules/`
patternlab.installplugin(pluginname); // void
// returns all file extensions supported by installed PatternEngines
patternlab.getSupportedTemplateExtensions(); // ['.handlebars', '.hbs']
All 2.X methods, except where noted below.
build (callback, options)
patternsonly(callback, options)
enablePlugin
disablePlugin
export
getSupportedTemplateExtensions renamed to getsupportedtemplateextensions
// serve locally, after initial build
// automatically sets watch = true
patternlab.serve(callback, options);
events
patternlab.serve(...);
patternlab.events.on('patternlab-asset-change', (data) => {
console.log(data); // {file: 'path/to/file.css', dest: 'path/to/destination'}
})
patternlab.events.on('patternlab-pattern-change', (data) => {
console.log(data); // {file: 'path/to/file.ext'}
})