forked from keycloak/keycloak-nodejs-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
80 lines (68 loc) · 1.75 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
75
76
77
78
79
var fs = require('fs');
var path = require('path');
function rmdir(dir) {
if ( ! fs.existsSync(dir) ) {
return;
}
var entries = fs.readdirSync(dir);
entries.forEach( function(e) {
var stat = fs.statSync(path.join(dir, e));
if ( stat.isDirectory() ) {
rmdir(path.join(dir,e));
} else {
fs.unlinkSync(path.join(dir,e));
}
} );
fs.rmdirSync(dir);
}
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
touch: {
src: [ 'site/.nojekyll' ]
},
run_grunt: {
site: {
src: [ 'connect/Gruntfile.js', 'auth-utils/Gruntfile.js' ],
options: {
log: false,
process: function(res){
var dir = path.dirname( res.src );
rmdir(path.join('.', 'site', dir ));
fs.linkSync( dir + '/doc', './site/' + dir );
}
},
}
},
markdown: {
all: {
files: [
{
expand: true,
src: 'site/*.md',
ext: '.html'
}
]
}
},
'gh-pages': {
options: {
base: 'site',
dotfiles: true,
},
src: ['**/*']
}
});
grunt.registerTask( 'finish-site', 'Finish assembling the site', function() {
if ( fs.existsSync(path.join('.', 'site', 'index.md' ) ) ) {
fs.unlinkSync(path.join('.','site','index.md'));
}
fs.linkSync( path.join('.', 'README.md'), path.join( '.', 'site', 'index.md' ) );
} );
grunt.loadNpmTasks('grunt-touch');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-run-grunt');
grunt.loadNpmTasks('grunt-markdown');
// Default task(s).
grunt.registerTask('default', ['touch', 'run_grunt:site', 'finish-site', 'markdown']);
};