@@ -77,20 +77,15 @@ function getDuplicateIndex(assetPath) {
77
77
var index = 0 ;
78
78
var duplicatePath ;
79
79
if ( fs . existsSync ( assetPath ) ) {
80
-
81
- duplicatePath = composeDuplicatePath ( assetPath , ++ index ) ;
82
- console . log ( chalk . magenta ( index ) )
83
- while ( fs . existsSync ( duplicatePath ) ) {
84
-
80
+ do {
85
81
duplicatePath = composeDuplicatePath ( assetPath , ++ index ) ;
86
- }
82
+ } while ( fs . existsSync ( duplicatePath ) )
87
83
}
88
84
return index ;
89
85
90
86
}
91
87
//get asset content
92
88
function getAsset ( filePath ) {
93
-
94
89
if ( fs . existsSync ( filePath ) ) {
95
90
return fs . readFileSync ( filePath ) ;
96
91
} else {
@@ -124,13 +119,13 @@ function processUrlRebase(dirname, url, to, options) {
124
119
absoluteAssetsPath = path . join ( absoluteAssetsPath , fileName ) ;
125
120
relativeAssetsPath = path . join ( relativeAssetsPath , fileName ) ;
126
121
127
- if ( options . renameDuplicates )
128
- {
122
+ if ( options . renameDuplicates ) {
129
123
var index = getDuplicateIndex ( absoluteAssetsPath ) ;
130
124
if ( index ) {
131
- absoluteAssetsPath = composeDuplicatePath ( absoluteAssetsPath , index ) ;
132
125
relativeAssetsPath = composeDuplicatePath ( relativeAssetsPath , index ) ;
133
-
126
+ absoluteAssetsPath = composeDuplicatePath ( absoluteAssetsPath , index ) ;
127
+ console . warn ( chalk . yellow ( 'postcss-assets-rebase: duplicated path \'' + filePath + '\' renamed to: ' +
128
+ relativeAssetsPath ) ) ;
134
129
}
135
130
}
136
131
copyAsset ( absoluteAssetsPath , assetContents ) ;
0 commit comments