@@ -42,6 +42,10 @@ module.exports = function(options, emitter) {
42
42
renderOptions . file = options . src ;
43
43
}
44
44
45
+ var sourceMap = options . sourceMap ;
46
+ var destination = options . dest ;
47
+ var stdin = options . stdin ;
48
+
45
49
var success = function ( result ) {
46
50
var todo = 1 ;
47
51
var done = function ( ) {
@@ -50,10 +54,10 @@ module.exports = function(options, emitter) {
50
54
}
51
55
} ;
52
56
53
- if ( ! options . dest || options . stdin ) {
57
+ if ( ! destination || stdin ) {
54
58
emitter . emit ( 'log' , result . css . toString ( ) ) ;
55
59
56
- if ( options . sourceMap ) {
60
+ if ( sourceMap ) {
57
61
emitter . emit ( 'log' , result . map . toString ( ) ) ;
58
62
}
59
63
@@ -62,36 +66,36 @@ module.exports = function(options, emitter) {
62
66
63
67
emitter . emit ( 'warn' , chalk . green ( 'Rendering Complete, saving .css file...' ) ) ;
64
68
65
- mkdirp ( path . dirname ( options . dest ) , function ( err ) {
69
+ mkdirp ( path . dirname ( destination ) , function ( err ) {
66
70
if ( err ) {
67
71
return emitter . emit ( 'error' , chalk . red ( err ) ) ;
68
72
}
69
73
70
- fs . writeFile ( options . dest , result . css . toString ( ) , function ( err ) {
74
+ fs . writeFile ( destination , result . css . toString ( ) , function ( err ) {
71
75
if ( err ) {
72
76
return emitter . emit ( 'error' , chalk . red ( err ) ) ;
73
77
}
74
78
75
- emitter . emit ( 'warn' , chalk . green ( 'Wrote CSS to ' + options . dest ) ) ;
76
- emitter . emit ( 'write' , err , options . dest , result . css . toString ( ) ) ;
79
+ emitter . emit ( 'warn' , chalk . green ( 'Wrote CSS to ' + destination ) ) ;
80
+ emitter . emit ( 'write' , err , destination , result . css . toString ( ) ) ;
77
81
done ( ) ;
78
82
} ) ;
79
83
} ) ;
80
84
81
- if ( options . sourceMap ) {
85
+ if ( sourceMap ) {
82
86
todo ++ ;
83
87
84
- mkdirp ( path . dirname ( options . sourceMap ) , function ( err ) {
88
+ mkdirp ( path . dirname ( sourceMap ) , function ( err ) {
85
89
if ( err ) {
86
90
return emitter . emit ( 'error' , chalk . red ( err ) ) ;
87
91
}
88
- fs . writeFile ( options . sourceMap , result . map , function ( err ) {
92
+ fs . writeFile ( sourceMap , result . map , function ( err ) {
89
93
if ( err ) {
90
94
return emitter . emit ( 'error' , chalk . red ( 'Error' + err ) ) ;
91
95
}
92
96
93
- emitter . emit ( 'warn' , chalk . green ( 'Wrote Source Map to ' + options . sourceMap ) ) ;
94
- emitter . emit ( 'write-source-map' , err , options . sourceMap , result . map ) ;
97
+ emitter . emit ( 'warn' , chalk . green ( 'Wrote Source Map to ' + sourceMap ) ) ;
98
+ emitter . emit ( 'write-source-map' , err , sourceMap , result . map ) ;
95
99
done ( ) ;
96
100
} ) ;
97
101
} ) ;
0 commit comments