11import * as fs from "fs" ;
2- import * as path from "path" ;
2+ import { join , dirname , basename , resolve as pathResolve , extname , normalize } from "path" ;
33import * as minimatch from "minimatch" ;
44import * as injector from "./yok" ;
55import * as crypto from "crypto" ;
@@ -74,7 +74,7 @@ export class FileSystem implements IFileSystem {
7474
7575 let proc : string ;
7676 if ( $hostInfo . isWindows ) {
77- proc = path . join ( __dirname , "resources/platform-tools/unzip/win32/unzip" ) ;
77+ proc = join ( __dirname , "resources/platform-tools/unzip/win32/unzip" ) ;
7878 } else if ( $hostInfo . isDarwin ) {
7979 proc = "unzip" ; // darwin unzip is info-zip
8080 } else if ( $hostInfo . isLinux ) {
@@ -98,11 +98,11 @@ export class FileSystem implements IFileSystem {
9898 }
9999
100100 private findFileCaseInsensitive ( file : string ) : string {
101- const dir = path . dirname ( file ) ;
102- const basename = path . basename ( file ) ;
101+ const dir = dirname ( file ) ;
102+ const baseName = basename ( file ) ;
103103 const entries = this . readDirectory ( dir ) ;
104- const match = minimatch . match ( entries , basename , { nocase : true , nonegate : true , nonull : true } ) [ 0 ] ;
105- const result = path . join ( dir , match ) ;
104+ const match = minimatch . match ( entries , baseName , { nocase : true , nonegate : true , nonull : true } ) [ 0 ] ;
105+ const result = join ( dir , match ) ;
106106 return result ;
107107 }
108108
@@ -204,7 +204,7 @@ export class FileSystem implements IFileSystem {
204204 }
205205
206206 public writeFile ( filename : string , data : string | NodeBuffer , encoding ?: string ) : void {
207- this . createDirectory ( path . dirname ( filename ) ) ;
207+ this . createDirectory ( dirname ( filename ) ) ;
208208 fs . writeFileSync ( filename , data , { encoding : encoding } ) ;
209209 }
210210
@@ -218,7 +218,7 @@ export class FileSystem implements IFileSystem {
218218 }
219219
220220 let stringifiedData ;
221- if ( path . basename ( filename ) === PACKAGE_JSON_FILE_NAME ) {
221+ if ( basename ( filename ) === PACKAGE_JSON_FILE_NAME ) {
222222 let newline = EOL ;
223223 if ( fs . existsSync ( filename ) ) {
224224 const existingFile = this . readText ( filename ) ;
@@ -233,11 +233,11 @@ export class FileSystem implements IFileSystem {
233233 }
234234
235235 public copyFile ( sourceFileName : string , destinationFileName : string ) : void {
236- if ( path . resolve ( sourceFileName ) === path . resolve ( destinationFileName ) ) {
236+ if ( pathResolve ( sourceFileName ) === pathResolve ( destinationFileName ) ) {
237237 return ;
238238 }
239239
240- this . createDirectory ( path . dirname ( destinationFileName ) ) ;
240+ this . createDirectory ( dirname ( destinationFileName ) ) ;
241241
242242 // MobileApplication.app is resolved as a directory on Mac,
243243 // therefore we need to copy it recursively as it's not a single file.
@@ -284,8 +284,8 @@ export class FileSystem implements IFileSystem {
284284 if ( ! this . exists ( baseName ) ) {
285285 return baseName ;
286286 }
287- const extension = path . extname ( baseName ) ;
288- const prefix = path . basename ( baseName , extension ) ;
287+ const extension = extname ( baseName ) ;
288+ const prefix = basename ( baseName , extension ) ;
289289
290290 for ( let i = 2 ; ; ++ i ) {
291291 const numberedName = prefix + i + extension ;
@@ -301,8 +301,8 @@ export class FileSystem implements IFileSystem {
301301 }
302302
303303 public isRelativePath ( p : string ) : boolean {
304- const normal = path . normalize ( p ) ;
305- const absolute = path . resolve ( p ) ;
304+ const normal = normalize ( p ) ;
305+ const absolute = pathResolve ( p ) ;
306306 return normal !== absolute ;
307307 }
308308
@@ -357,7 +357,7 @@ export class FileSystem implements IFileSystem {
357357
358358 const contents = this . readDirectory ( directoryPath ) ;
359359 for ( let i = 0 ; i < contents . length ; ++ i ) {
360- const file = path . join ( directoryPath , contents [ i ] ) ;
360+ const file = join ( directoryPath , contents [ i ] ) ;
361361 let stat : fs . Stats = null ;
362362 if ( this . exists ( file ) ) {
363363 stat = this . getFsStats ( file ) ;
@@ -420,11 +420,11 @@ export class FileSystem implements IFileSystem {
420420 }
421421
422422 public deleteEmptyParents ( directory : string ) : void {
423- let parent = this . exists ( directory ) ? directory : path . dirname ( directory ) ;
423+ let parent = this . exists ( directory ) ? directory : dirname ( directory ) ;
424424
425425 while ( this . isEmptyDir ( parent ) ) {
426426 this . deleteDirectory ( parent ) ;
427- parent = path . dirname ( parent ) ;
427+ parent = dirname ( parent ) ;
428428 }
429429 }
430430
0 commit comments