1
1
'use strict' ;
2
2
3
+ var sdfs = require ( './src/file' ) ;
4
+ var spawn = require ( 'win-spawn' ) ;
5
+ var chalk = require ( 'chalk' ) ;
6
+
3
7
module . exports = function ( grunt ) {
4
8
5
9
// Load all grunt tasks matching the `grunt-*` pattern.
@@ -8,17 +12,13 @@ module.exports = function (grunt) {
8
12
// Time how long tasks take.
9
13
require ( 'time-grunt' ) ( grunt ) ;
10
14
11
- // Require SassDoc file utils.
12
- var sdfs = require ( './src/file' ) ;
13
-
14
15
// Project specific paths.
15
16
var dirs = {
16
- cwd : '.' ,
17
- base : 'examples/dist' , // Server base.
18
- dist : 'examples/dist' ,
17
+ cwd : __dirname ,
19
18
scss : 'view/scss' ,
20
19
css : 'view/assets/css' ,
21
20
tpl : 'view/templates' ,
21
+ dist : 'examples/dist' ,
22
22
src : 'src' ,
23
23
test : 'src/annotation/annotations/test'
24
24
} ;
@@ -34,7 +34,7 @@ module.exports = function (grunt) {
34
34
options : {
35
35
style : 'compressed'
36
36
} ,
37
- view : {
37
+ dist : {
38
38
files : [ {
39
39
expand : true ,
40
40
cwd : '<%= dirs.scss %>' ,
@@ -67,7 +67,7 @@ module.exports = function (grunt) {
67
67
watch : {
68
68
scss : {
69
69
files : [ '<%= dirs.scss %>/**/*.scss' ] ,
70
- tasks : [ 'sass:view ' ]
70
+ tasks : [ 'sass:dist ' ]
71
71
} ,
72
72
tpl : {
73
73
files : [ '<%= dirs.tpl %>/**/*.swig' ] ,
@@ -87,7 +87,7 @@ module.exports = function (grunt) {
87
87
options : {
88
88
watchTask : true ,
89
89
server : {
90
- baseDir : '<%= dirs.base %>'
90
+ baseDir : '<%= dirs.dist %>'
91
91
}
92
92
}
93
93
}
@@ -100,20 +100,22 @@ module.exports = function (grunt) {
100
100
grunt . registerTask ( 'compile' , 'Generates documentation' , function ( ) {
101
101
var done = this . async ( ) ;
102
102
103
- grunt . util . spawn ( {
104
- cmd : 'bin/sassdoc' ,
105
- args : [ 'view/scss/utils' , 'examples/dist' , '--verbose' ]
106
- } ,
103
+ // Temporary fix for #73
104
+ var src = dirs . scss + '/utils' ;
105
+ var args = [ src , dirs . dist , '--verbose' ] ;
107
106
108
- function ( error , result ) {
109
- if ( error ) {
110
- grunt . log . error ( error ) ;
111
- }
107
+ var cp = spawn ( './bin/sassdoc' , args , { stdio : 'inherit' } ) ;
108
+
109
+ cp . on ( 'error' , function ( err ) {
110
+ grunt . warn ( err ) ;
111
+ } ) ;
112
112
113
- if ( result ) {
114
- grunt . log . writeln ( result ) ;
113
+ cp . on ( 'close' , function ( code ) {
114
+ if ( code > 0 ) {
115
+ return grunt . warn ( 'Exited with error code ' + code ) ;
115
116
}
116
117
118
+ grunt . log . writeln ( 'File ' + chalk . cyan ( dirs . dist ) + ' created.' ) ;
117
119
done ( ) ;
118
120
} ) ;
119
121
} ) ;
@@ -126,7 +128,7 @@ module.exports = function (grunt) {
126
128
}
127
129
} ) ;
128
130
129
- // While working on the view.
131
+ // While working on the view/examples .
130
132
grunt . registerTask ( 'dist' , [
131
133
'browserSync:dist' ,
132
134
'watch'
0 commit comments