@@ -11,73 +11,73 @@ var md5 = require('md5');
1111var fileExists = require ( 'file-exists' ) ;
1212
1313module . exports = function ( opt ) {
14- var options = merge ( {
15- output_assets : null ,
16- output_css : null ,
17- exclude : [ ] ,
18- overwrite : false
19- } , opt ) ;
14+ var options = merge ( {
15+ output_assets : null ,
16+ output_css : null ,
17+ exclude : [ ] ,
18+ overwrite : false
19+ } , opt ) ;
2020
21- return through . obj ( function ( file , enc , cb ) {
22- if ( file . isNull ( ) ) {
23- return ;
24- }
21+ return through . obj ( function ( file , enc , cb ) {
22+ if ( file . isNull ( ) ) {
23+ return ;
24+ }
2525
26- if ( file . isStream ( ) ) {
27- return this . emit ( 'error' , PluginError ( 'gulp-css-rebase' , 'Streaming not supported' ) ) ;
28- }
26+ if ( file . isStream ( ) ) {
27+ return this . emit ( 'error' , PluginError ( 'gulp-css-rebase' , 'Streaming not supported' ) ) ; // eslint-disable-line
28+ }
2929
30- var adjusted = adjust ( file ) ;
31- file . contents = new Buffer ( adjusted ) ;
30+ var adjusted = adjust ( file ) ;
31+ file . contents = new Buffer ( adjusted ) ;
3232
33- cb ( null , file ) ;
34- } ) ;
33+ cb ( null , file ) ;
34+ } ) ;
3535
36- function adjust ( file ) {
37- var css = file . contents . toString ( ) ;
36+ function adjust ( file ) {
37+ var css = file . contents . toString ( ) ;
3838
39- return rework ( css )
39+ return rework ( css )
4040 . use ( url ( function ( url ) {
41- if ( ! / ^ ( d a t a | \/ | \w + : \/ \/ ) / . test ( url ) ) {
42- var assetPath = path . join ( path . dirname ( file . path ) , url ) ;
43- var assetFolder = md5 ( path . relative ( process . cwd ( ) , path . dirname ( assetPath ) ) ) ;
44- var IsExclude = false ;
41+ if ( ! / ^ ( d a t a | \/ | \w + : \/ \/ ) / . test ( url ) ) {
42+ var assetPath = path . join ( path . dirname ( file . path ) , url ) ;
43+ var assetFolder = md5 ( path . relative ( process . cwd ( ) , path . dirname ( assetPath ) ) ) ;
44+ var IsExclude = false ;
4545
46- for ( var index in options . exclude ) {
47- if ( options . exclude [ index ] === assetPath . substr ( 0 , options . exclude [ index ] . length ) ) {
48- IsExclude = true ;
49- break ;
50- }
51- }
46+ for ( var index in options . exclude ) {
47+ if ( options . exclude [ index ] === assetPath . substr ( 0 , options . exclude [ index ] . length ) ) {
48+ IsExclude = true ;
49+ break ;
50+ }
51+ }
5252
53- var newPath = ! IsExclude
53+ var newPath = ! IsExclude
5454 ? path . normalize ( path . join ( options . output_assets , assetFolder , path . basename ( assetPath ) ) )
5555 : path . normalize ( assetPath )
5656 ;
5757
58- if (
58+ if (
5959 ( ! IsExclude && ! fileExists ( newPath ) )
6060 ||
6161 ( ! IsExclude && options . overwrite )
6262 ) {
63- mkpath ( path . dirname ( newPath ) , function ( err ) {
64- if ( err ) {
65- throw err ;
66- }
63+ mkpath ( path . dirname ( newPath ) , function ( err ) {
64+ if ( err ) {
65+ throw err ;
66+ }
6767
68- fs
68+ fs
6969 . createReadStream ( assetPath . replace ( / [ \# | \? ] .* $ / , '' ) )
7070 . pipe ( fs . createWriteStream ( newPath . replace ( / [ \# | \? ] .* $ / , '' ) ) )
7171 ;
72- } ) ;
72+ } ) ;
7373
74- }
75-
76- url = path . relative ( options . output_css , newPath ) ;
7774 }
7875
79- return url ;
76+ url = path . relative ( options . output_css , newPath ) ;
77+ }
78+
79+ return url ;
8080 } ) )
8181 . toString ( ) ;
82- }
82+ }
8383} ;
0 commit comments