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