@@ -59,8 +59,8 @@ assert.strictEqual(path.posix.basename('foo'), 'foo');
59
59
60
60
// POSIX filenames may include control characters
61
61
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
62
- const controlCharFilename = ' Icon' + String . fromCharCode ( 13 ) ;
63
- assert . strictEqual ( path . posix . basename ( ' /a/b/' + controlCharFilename ) ,
62
+ const controlCharFilename = ` Icon${ String . fromCharCode ( 13 ) } ` ;
63
+ assert . strictEqual ( path . posix . basename ( ` /a/b/${ controlCharFilename } ` ) ,
64
64
controlCharFilename ) ;
65
65
66
66
@@ -160,8 +160,8 @@ assert.strictEqual(path.win32.dirname('foo'), '.');
160
160
[ 'file//' , '' ] ,
161
161
[ 'file./' , '.' ] ,
162
162
[ 'file.//' , '.' ] ,
163
- ] . forEach ( function ( test ) {
164
- [ path . posix . extname , path . win32 . extname ] . forEach ( function ( extname ) {
163
+ ] . forEach ( ( test ) => {
164
+ [ path . posix . extname , path . win32 . extname ] . forEach ( ( extname ) => {
165
165
let input = test [ 0 ] ;
166
166
let os ;
167
167
if ( extname === path . win32 . extname ) {
@@ -208,6 +208,7 @@ const joinTests = [
208
208
[ [ path . posix . join , path . win32 . join ] ,
209
209
// arguments result
210
210
[ [ [ '.' , 'x/b' , '..' , '/b/c.js' ] , 'x/b/c.js' ] ,
211
+ [ [ ] , '.' ] ,
211
212
[ [ '/.' , 'x/b' , '..' , '/b/c.js' ] , '/x/b/c.js' ] ,
212
213
[ [ '/foo' , '../../../bar' ] , '/bar' ] ,
213
214
[ [ 'foo' , '../../../bar' ] , '../../bar' ] ,
@@ -310,11 +311,11 @@ joinTests.push([
310
311
]
311
312
)
312
313
] ) ;
313
- joinTests . forEach ( function ( test ) {
314
+ joinTests . forEach ( ( test ) => {
314
315
if ( ! Array . isArray ( test [ 0 ] ) )
315
316
test [ 0 ] = [ test [ 0 ] ] ;
316
- test [ 0 ] . forEach ( function ( join ) {
317
- test [ 1 ] . forEach ( function ( test ) {
317
+ test [ 0 ] . forEach ( ( join ) => {
318
+ test [ 1 ] . forEach ( ( test ) => {
318
319
const actual = join . apply ( null , test [ 0 ] ) ;
319
320
const expected = test [ 1 ] ;
320
321
// For non-Windows specific tests with the Windows join(), we need to try
@@ -333,7 +334,7 @@ joinTests.forEach(function(test) {
333
334
'\n expect=' + JSON . stringify ( expected ) +
334
335
'\n actual=' + JSON . stringify ( actual ) ;
335
336
if ( actual !== expected && actualAlt !== expected )
336
- failures . push ( '\n' + message ) ;
337
+ failures . push ( `\n ${ message } ` ) ;
337
338
} ) ;
338
339
} ) ;
339
340
} ) ;
@@ -344,15 +345,15 @@ assert.strictEqual(failures.length, 0, failures.join(''));
344
345
const typeErrorTests = [ true , false , 7 , null , { } , undefined , [ ] , NaN ] ;
345
346
346
347
function fail ( fn ) {
347
- const args = Array . prototype . slice . call ( arguments , 1 ) ;
348
+ const args = Array . from ( arguments ) . slice ( 1 ) ;
348
349
349
- assert . throws ( function ( ) {
350
+ assert . throws ( ( ) => {
350
351
fn . apply ( null , args ) ;
351
352
} , TypeError ) ;
352
353
}
353
354
354
- typeErrorTests . forEach ( function ( test ) {
355
- [ path . posix , path . win32 ] . forEach ( function ( namespace ) {
355
+ typeErrorTests . forEach ( ( test ) => {
356
+ [ path . posix , path . win32 ] . forEach ( ( namespace ) => {
356
357
fail ( namespace . join , test ) ;
357
358
fail ( namespace . resolve , test ) ;
358
359
fail ( namespace . normalize , test ) ;
@@ -396,7 +397,7 @@ assert.strictEqual(path.posix.normalize('///..//./foo/.//bar'), '/foo/bar');
396
397
// path.resolve tests
397
398
const resolveTests = [
398
399
[ path . win32 . resolve ,
399
- // arguments result
400
+ // arguments result
400
401
[ [ [ 'c:/blah\\blah' , 'd:/games' , 'c:../a' ] , 'c:\\blah\\a' ] ,
401
402
[ [ 'c:/ignore' , 'd:\\a/b\\c/d' , '\\e.exe' ] , 'd:\\e.exe' ] ,
402
403
[ [ 'c:/ignore' , 'c:/some/file' ] , 'c:\\some\\file' ] ,
@@ -413,7 +414,7 @@ const resolveTests = [
413
414
]
414
415
] ,
415
416
[ path . posix . resolve ,
416
- // arguments result
417
+ // arguments result
417
418
[ [ [ '/var/lib' , '../' , 'file/' ] , '/var/file' ] ,
418
419
[ [ '/var/lib' , '/../' , 'file/' ] , '/file' ] ,
419
420
[ [ 'a/b/c/' , '../../..' ] , process . cwd ( ) ] ,
@@ -423,9 +424,9 @@ const resolveTests = [
423
424
]
424
425
]
425
426
] ;
426
- resolveTests . forEach ( function ( test ) {
427
+ resolveTests . forEach ( ( test ) => {
427
428
const resolve = test [ 0 ] ;
428
- test [ 1 ] . forEach ( function ( test ) {
429
+ test [ 1 ] . forEach ( ( test ) => {
429
430
const actual = resolve . apply ( null , test [ 0 ] ) ;
430
431
let actualAlt ;
431
432
const os = resolve === path . win32 . resolve ? 'win32' : 'posix' ;
@@ -514,7 +515,7 @@ const relativeTests = [
514
515
]
515
516
] ,
516
517
[ path . posix . relative ,
517
- // arguments result
518
+ // arguments result
518
519
[ [ '/var/lib' , '/var' , '..' ] ,
519
520
[ '/var/lib' , '/bin' , '../../bin' ] ,
520
521
[ '/var/lib' , '/var/lib' , '' ] ,
@@ -530,9 +531,9 @@ const relativeTests = [
530
531
]
531
532
]
532
533
] ;
533
- relativeTests . forEach ( function ( test ) {
534
+ relativeTests . forEach ( ( test ) => {
534
535
const relative = test [ 0 ] ;
535
- test [ 1 ] . forEach ( function ( test ) {
536
+ test [ 1 ] . forEach ( ( test ) => {
536
537
const actual = relative ( test [ 0 ] , test [ 1 ] ) ;
537
538
const expected = test [ 2 ] ;
538
539
const os = relative === path . win32 . relative ? 'win32' : 'posix' ;
@@ -543,7 +544,7 @@ relativeTests.forEach(function(test) {
543
544
'\n expect=' + JSON . stringify ( expected ) +
544
545
'\n actual=' + JSON . stringify ( actual ) ;
545
546
if ( actual !== expected )
546
- failures . push ( '\n' + message ) ;
547
+ failures . push ( `\n ${ message } ` ) ;
547
548
} ) ;
548
549
} ) ;
549
550
assert . strictEqual ( failures . length , 0 , failures . join ( '' ) ) ;
@@ -575,14 +576,14 @@ if (common.isWindows) {
575
576
// These tests cause resolve() to insert the cwd, so we cannot test them from
576
577
// non-Windows platforms (easily)
577
578
assert . strictEqual ( path . win32 . _makeLong ( 'foo\\bar' ) . toLowerCase ( ) ,
578
- ' \\\\?\\' + process . cwd ( ) . toLowerCase ( ) + ' \\foo\\bar' ) ;
579
+ ` \\\\?\\${ process . cwd ( ) . toLowerCase ( ) } \\foo\\bar` ) ;
579
580
assert . strictEqual ( path . win32 . _makeLong ( 'foo/bar' ) . toLowerCase ( ) ,
580
- ' \\\\?\\' + process . cwd ( ) . toLowerCase ( ) + ' \\foo\\bar' ) ;
581
+ ` \\\\?\\${ process . cwd ( ) . toLowerCase ( ) } \\foo\\bar` ) ;
581
582
const currentDeviceLetter = path . parse ( process . cwd ( ) ) . root . substring ( 0 , 2 ) ;
582
583
assert . strictEqual ( path . win32 . _makeLong ( currentDeviceLetter ) . toLowerCase ( ) ,
583
- ' \\\\?\\' + process . cwd ( ) . toLowerCase ( ) ) ;
584
+ ` \\\\?\\${ process . cwd ( ) . toLowerCase ( ) } ` ) ;
584
585
assert . strictEqual ( path . win32 . _makeLong ( 'C' ) . toLowerCase ( ) ,
585
- ' \\\\?\\' + process . cwd ( ) . toLowerCase ( ) + ' \\c' ) ;
586
+ ` \\\\?\\${ process . cwd ( ) . toLowerCase ( ) } \\c` ) ;
586
587
}
587
588
assert . strictEqual ( path . win32 . _makeLong ( 'C:\\foo' ) , '\\\\?\\C:\\foo' ) ;
588
589
assert . strictEqual ( path . win32 . _makeLong ( 'C:/foo' ) , '\\\\?\\C:\\foo' ) ;
0 commit comments