@@ -6,6 +6,7 @@ import Future = require("fibers/future");
6
6
import path = require( "path" ) ;
7
7
import util = require( "util" ) ;
8
8
import rimraf = require( "rimraf" ) ;
9
+ import minimatch = require( "minimatch" ) ;
9
10
import hostInfo = require( "./host-info" ) ;
10
11
11
12
export class FileSystem implements IFileSystem {
@@ -55,20 +56,38 @@ export class FileSystem implements IFileSystem {
55
56
return ( ( ) => {
56
57
var shouldOverwriteFiles = ! ( options && options . overwriteExisitingFiles === false ) ;
57
58
var isCaseSensitive = ! ( options && options . caseSensitive === false ) ;
58
-
59
- //the wild card symbol at the end is required in order for the -ssc- switch of 7zip to behave properly
60
- zipFile = isCaseSensitive ? zipFile : zipFile + '*' ;
61
59
62
60
this . createDirectory ( destinationDir ) . wait ( ) ;
63
- var args = < string [ ] > ( _ . flatten ( [ 'x' , shouldOverwriteFiles ? "-y" : "-aos" , '-o' + destinationDir , isCaseSensitive ? '-ssc' : '-ssc-' , zipFile , fileFilters || [ ] ] ) ) ;
64
61
65
- var $childProcess = this . $injector . resolve ( "childProcess" ) ;
66
- var $staticConfig = this . $injector . resolve ( "staticConfig" ) ;
62
+ var proc : string ;
63
+ if ( hostInfo . isWindows ( ) ) {
64
+ proc = path . join ( __dirname , "resources/platform-tools/unzip/win32/unzip" ) ;
65
+ } else if ( hostInfo . isDarwin ( ) ) {
66
+ proc = "unzip" ; // darwin unzip is info-zip
67
+ } else if ( hostInfo . isLinux ( ) ) {
68
+ proc = "unzip" ; // linux unzip is info-zip
69
+ }
70
+
71
+ if ( ! isCaseSensitive ) {
72
+ zipFile = this . findFileCaseInsensitive ( zipFile ) ;
73
+ }
74
+
75
+ var args = < string [ ] > ( _ . flatten ( [ '-b' , shouldOverwriteFiles ? "-o" : "-n" , isCaseSensitive ? [ ] : '-C' , zipFile , fileFilters || [ ] , '-d' , destinationDir ] ) ) ;
67
76
68
- $childProcess . spawnFromEvent ( $staticConfig . sevenZipFilePath , args , "close" , { stdio : "ignore" , detached : true } ) . wait ( ) ;
77
+ var $childProcess = this . $injector . resolve ( "childProcess" ) ;
78
+ $childProcess . spawnFromEvent ( proc , args , "close" , { stdio : "ignore" , detached : true } ) . wait ( ) ;
69
79
} ) . future < void > ( ) ( ) ;
70
80
}
71
81
82
+ private findFileCaseInsensitive ( file : string ) : string {
83
+ var dir = path . dirname ( file ) ;
84
+ var basename = path . basename ( file ) ;
85
+ var entries = this . readDirectory ( dir ) . wait ( ) ;
86
+ var match = minimatch . match ( entries , basename , { nocase :true , nonegate : true , nonull : true } ) [ 0 ] ;
87
+ var result = path . join ( dir , match ) ;
88
+ return result ;
89
+ }
90
+
72
91
public exists ( path : string ) : IFuture < boolean > {
73
92
var future = new Future < boolean > ( ) ;
74
93
fs . exists ( path , ( exists : boolean ) => future . return ( exists ) ) ;
0 commit comments