forked from blackbaud/skyux-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
74 lines (62 loc) · 2.21 KB
/
gruntfile.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
/*jslint node: true, nomen: true, plusplus: true */
'use strict';
module.exports = function (grunt) {
var skySrcPath = 'sky-jsdoc/sky-';
// Load Blackbaud Stache config
grunt.task.loadNpmTasks('grunt-jsdoc-to-markdown');
grunt.task.loadNpmTasks('blackbaud-stache');
// Add our necessary configuration information
grunt.config.merge({
stache: {
hooks: {
preStache: [
'getLatestSkyRelease'
],
preAssemble: [
'setModalFullLayout'
]
},
pages: [{
url: skySrcPath + '<%= stache.config.latest_sky_release %>.json',
dest: 'components/',
type: 'jsdoc'
}]
}
});
/**
* Sets the layout of the modalfull example.
**/
grunt.registerTask('setModalFullLayout', function () {
var key = 'assemble.custom.options.pages',
pages = grunt.config.get(key);
pages['components/modalfull/index.md'].data.layout =
'../../../../includes/bb-page-layout';
grunt.config.set(key, pages);
});
/**
* Reads the latest sky release file if it exists.
* This file is automatically created via Travis.
**/
grunt.registerTask('getLatestSkyRelease', function () {
var file = 'includes/latest-release.txt',
key = 'stache.config.latest_sky_release',
sriFile,
v;
v = grunt.config.get(key);
if (grunt.file.exists(file)) {
v = grunt.file.read(file, 'utf8').replace(/(\r\n|\n|\r)/gm, '');
// Verify it exists
if (grunt.file.exists(skySrcPath + v + '.json')) {
grunt.config.set(key, v);
} else {
grunt.fail.warn('The version specified in latest-release.txt does not exist in sky-jsdoc: ' + v);
}
} else {
grunt.log.writeln('Latest sky release not specified. Defaulting to: ' + v);
}
sriFile = 'sky-sri/sky-' + v + '.json';
if (grunt.file.exists(sriFile)) {
grunt.config.set('stache.config.latest_sky_sri', grunt.file.readJSON(sriFile));
}
});
};