-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
79 lines (71 loc) · 2.28 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* This module is used to load the base KSS builder class needed by this builder
* and to define any custom CLI options or extend any base class methods.
*
* Note: since this builder wants to extend the KssBuilderBaseTwig class, it
* must export a KssBuilderBaseTwig sub-class as a module. Otherwise, kss-node
* will assume the builder wants to use the KssBuilderBaseHandlebars class.
*
* This file’s name should follow standard node.js require() conventions. It
* should either be named index.js or have its name set in the “main” property
* of the builder’s package.json. See
* http://nodejs.org/api/modules.html#modules_folders_as_modules
*
* @module kss/builder/twig
*/
const path = require('path')
// We want to extend kss-node’s Twig builder so we can add options that
// are used in our templates.
// This module is not resolved because it’s a peerDependency.
const KssBuilderBaseTwig = require('kss/builder/base/twig') // eslint-disable-line import/no-unresolved
/**
* A kss-node builder that takes input files and builds a style guide using Twig
* templates.
*/
class KssBuilderTwig extends KssBuilderBaseTwig {
/**
* Create a builder object.
*/
constructor() {
// First call the constructor of KssBuilderBaseTwig.
super()
// Then tell kss which Yargs-like options this builder adds.
this.addOptionDefinitions({
title: {
group: 'Style guide:',
string: true,
multiple: false,
describe: 'Title of the style guide',
default: 'KSS Style Guide',
},
svgSprite: {
group: 'SVG sprite:',
string: true,
path: false,
multiple: false,
describe: 'SVG sprite',
},
svgPrefix: {
group: 'SVG sprite:',
string: true,
path: false,
multiple: false,
describe: 'Prefix for SVG IDs',
default: 'symbol-',
},
})
}
prepareExtend(templateEngine) {
this.options.extend.push(path.resolve(__dirname, 'extend'))
return super.prepareExtend(templateEngine)
}
normalizeOptions(keys) {
if (this.options.custom) {
this.options.custom = Array.from(new Set(this.options.custom.concat([
'symbols',
])))
}
return super.normalizeOptions(keys)
}
}
module.exports = KssBuilderTwig