-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
86 lines (70 loc) · 2.2 KB
/
gulpfile.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
80
81
82
83
84
85
86
var gulp = require('gulp');
var shell = require('gulp-shell');
var connect = require('gulp-connect');
var path = require('path');
var _ = require('lodash');
var glob = require('glob');
var clipboard = require('gulp-clipboard');
var join = path.join.bind(path);
var cwd = process.cwd();
// Test paths
var test = { path:'test/'};
_.extend(test, {
docs: { path: join(test.path, 'docs/') },
src: { path: join(test.path, 'source/') }
});
_.extend(test.docs, {
css: { path: join(test.docs.path, 'css/') },
js: { path: join(test.docs.path, 'js/') }
});
// Asset paths
var assets = { path:'assets/' };
_.extend(assets, {
css: { path: join(assets.path, 'css/') },
js: { path: join(assets.path, 'js/') }
});
// Doxx commands
var cmd = { source:' -s ', output:' -o ', template: ' -j ', kit:' -k ', name: ' -n '};
// Doxx commands with path
var source = cmd.source + join(cwd, test.src.path),
output = cmd.output + join(cwd, test.docs.path),
template = cmd.template + join(cwd, 'template/index.jade'),
kit = cmd.kit,
name = cmd.name + '"Mr. Doc\'s Default Theme"';
cmd = source + output + template + kit + name;
/** ---------------------- Tasks ---------------------- */
// Task 1: Build the docs
gulp.task('docs',shell.task([
'./node_modules/mr-doc/bin/mr-doc ' + cmd
]));
// Task 2: Copy the files from bower into js and assets
gulp.task('copy:js', ['docs'], function () {
return gulp.src(glob.sync(assets.js.path + '*.js'))
.pipe(clipboard())
.pipe(gulp.dest(test.docs.js.path));
});
// Task 3: Copy the files from bower into css
gulp.task('copy:css', ['docs'], function () {
return gulp.src(glob.sync(assets.css.path + '*.css'))
.pipe(gulp.dest(test.docs.css.path));
});
// Create server
gulp.task('connect', function() {
connect.server({
root: test.docs.path,
livereload: true
});
});
// Reload the page
gulp.task('html', function () {
gulp.src(test.docs.path + '*.html')
.pipe(connect.reload());
});
// Watch for changes
gulp.task('watch', function () {
gulp.watch(['template/*.jade','./*.md'], ['docs']);
});
// Default
gulp.task('default', ['build', 'copy:js', 'copy:css', 'connect', 'watch']);
// Build
gulp.task('build', ['docs']);