File tree 2 files changed +16
-9
lines changed
2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,17 @@ var urlRegex = /^(https?|webpack(-[^:]+)?):\/\//;
12
12
13
13
var debug = require ( 'debug-fabulous' ) ( ) ( PLUGIN_NAME + ':utils' ) ;
14
14
15
- var sourceMapUrlRegEx = / \/ \/ \# s o u r c e M a p p i n g U R L \= .* / g
15
+ /*
16
+ TODO: DROP SUPPORT FOR node <= 0.12.X
17
+ So reusing the same ref for a regex (with global (g))
18
+ is a major bug in node 0.10.X apparently.
19
+ See http://stackoverflow.com/questions/10229144/bug-with-regexp-in-javascript-when-do-global-search
20
+
21
+ So we either need to use a new instance of a regex everywhere
22
+ to make it compatible for all nodes 0.10.X + or drop support for 0.10.X.
23
+ For now we will continue to support it I guess. But this sucks.
24
+ */
25
+ var sourceMapUrlRegEx = function ( ) { return / \/ \/ \# s o u r c e M a p p i n g U R L \= .* / g; }
16
26
17
27
18
28
var getCommentFormatter = function ( file ) {
@@ -52,9 +62,9 @@ var getCommentFormatter = function (file) {
52
62
}
53
63
54
64
var getPreExisting = function ( fileContent ) {
55
- if ( sourceMapUrlRegEx . test ( fileContent ) ) {
65
+ if ( sourceMapUrlRegEx ( ) . test ( fileContent ) ) {
56
66
debug ( 'has preExisting' ) ;
57
- return fileContent . match ( sourceMapUrlRegEx ) [ 0 ] ;
67
+ return fileContent . match ( sourceMapUrlRegEx ( ) ) [ 0 ] ;
58
68
}
59
69
}
60
70
Original file line number Diff line number Diff line change @@ -161,13 +161,10 @@ function write(destPath, options) {
161
161
}
162
162
}
163
163
164
+ var preExisting = options . preExisting && utils . getPreExisting ( String ( file . contents ) ) ;
164
165
// append source map comment
165
- if ( options . addComment ) {
166
- if ( options . preExisting && utils . getPreExisting ( String ( file . contents ) ) ) {
167
- //normally the comment is pre-stripped but this option lets us know it is not
168
- }
169
- else
170
- file . contents = Buffer . concat ( [ file . contents , new Buffer ( comment ) ] ) ;
166
+ if ( options . addComment && ! preExisting ) {
167
+ file . contents = Buffer . concat ( [ file . contents , new Buffer ( comment ) ] ) ;
171
168
}
172
169
173
170
this . push ( file ) ;
You can’t perform that action at this time.
0 commit comments