@@ -6,6 +6,10 @@ function normalizeJsName(value) {
6
6
return value . trim ( ) . replace ( '-' , '_' ) . replace ( ' ' , '_' ) ;
7
7
}
8
8
9
+ function normalizePath ( input ) {
10
+ return path . normalize ( input ) . replace ( / [ \. ] + $ / , '' ) ;
11
+ }
12
+
9
13
function processFile ( file , options , callback ) {
10
14
var name = path . basename ( file , path . extname ( file ) ) ;
11
15
options . info ( '%s: started' , name ) ;
@@ -20,8 +24,14 @@ function processFile(file, options, callback) {
20
24
if ( ! options . isJSON ) {
21
25
content = options . processFileContent ( content , normalizeJsName ( name ) ) ;
22
26
}
27
+
28
+ const baseDir = normalizePath ( options . output ) || path . dirname ( file ) ;
29
+ const fileName = normalizePath ( options . processFileName ( name + ( options . isJSON ? '.json' : '.js' ) ) )
30
+
31
+ var outputPath = path . resolve ( baseDir , fileName ) ;
32
+
23
33
fs . writeFile (
24
- path . resolve ( options . output || path . dirname ( file ) , options . processFileName ( name + ( options . isJSON ? '.json' : '.js' ) ) ) ,
34
+ outputPath ,
25
35
content , function ( e ) {
26
36
e && options . error ( ' ' + e . message ) ;
27
37
callback ( ) ;
@@ -33,7 +43,8 @@ function processFile(file, options, callback) {
33
43
}
34
44
35
45
function collectFiles ( dir , done ) {
36
- var input = path . resolve ( dir || '' ) ;
46
+ var input = normalizePath ( path . resolve ( dir || '' ) ) ;
47
+
37
48
fs . stat ( input , function ( e , stat ) {
38
49
if ( e ) {
39
50
done ( e , [ ] ) ;
0 commit comments