@@ -102,7 +102,7 @@ export class SevenZipper {
102102 this . _event . emit ( 'progress' , 20 , line ) ;
103103 } ) ;
104104
105- process . Run ( 'tar' , paramList ) ;
105+ process . Run ( this . _tar_path ( ) , paramList ) ;
106106 } ) ;
107107 }
108108
@@ -154,13 +154,25 @@ export class SevenZipper {
154154 } ) ;
155155 }
156156
157+ private _is_tar ( path : string ) {
158+ return / \. t a r $ | \. t a r \. / . test ( path ) ;
159+ }
160+
161+ private _tar_path ( ) : string {
162+ if ( platform . osType ( ) == 'win32' ) {
163+ return ResManager . instance ( ) . getMsysBinToolPath ( 'tar' ) ;
164+ } else {
165+ return 'tar' ;
166+ }
167+ }
168+
157169 Unzip ( zipFile : File , outDir ?: File ) : Promise < Error | null > {
158170
159171 if ( ! zipFile . IsFile ( ) ) {
160172 throw new Error ( '\'' + zipFile . path + '\' is not exist' ) ;
161173 }
162174
163- if ( platform . osType ( ) != 'win32' && zipFile . suffix . startsWith ( 'tar' ) ) {
175+ if ( this . _is_tar ( zipFile . name ) ) {
164176 return this . _unzip_tar ( zipFile , outDir ) ;
165177 } else {
166178 return this . _unzip_zip_7z ( zipFile , outDir ) ;
@@ -174,15 +186,15 @@ export class SevenZipper {
174186 }
175187
176188 // use tar
177- if ( platform . osType ( ) != 'win32' && zipFile . suffix . startsWith ( 'tar' ) ) {
189+ if ( this . _is_tar ( zipFile . name ) ) {
178190
179191 let paramList : string [ ] = [ ] ;
180192
181193 paramList . push ( '-xvf' ) ;
182194 paramList . push ( zipFile . path ) ;
183195 paramList . push ( '-C' , outDir ? outDir . path : zipFile . dir ) ;
184196
185- return child_process . execFileSync ( 'tar' , paramList ) . toString ( ) ;
197+ return child_process . execFileSync ( this . _tar_path ( ) , paramList ) . toString ( ) ;
186198 }
187199 // use 7z
188200 else {
0 commit comments