2323const common = require ( '../common' ) ;
2424const assert = require ( 'assert' ) ;
2525const fs = require ( 'fs' ) ;
26- const join = require ( 'path' ) . join ;
2726
2827const tmpdir = require ( '../common/tmpdir' ) ;
2928
@@ -43,7 +42,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
4342
4443// Test that empty file will be created and have content added (callback API).
4544{
46- const filename = join ( tmpdir . path , 'append.txt' ) ;
45+ const filename = tmpdir . resolve ( 'append.txt' ) ;
4746
4847 fs . appendFile ( filename , s , common . mustSucceed ( ( ) => {
4948 fs . readFile ( filename , common . mustSucceed ( ( buffer ) => {
@@ -54,7 +53,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
5453
5554// Test that empty file will be created and have content added (promise API).
5655{
57- const filename = join ( tmpdir . path , 'append-promise.txt' ) ;
56+ const filename = tmpdir . resolve ( 'append-promise.txt' ) ;
5857
5958 fs . promises . appendFile ( filename , s )
6059 . then ( common . mustCall ( ( ) => fs . promises . readFile ( filename ) ) )
@@ -66,7 +65,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
6665
6766// Test that appends data to a non-empty file (callback API).
6867{
69- const filename = join ( tmpdir . path , 'append-non-empty.txt' ) ;
68+ const filename = tmpdir . resolve ( 'append-non-empty.txt' ) ;
7069 fs . writeFileSync ( filename , currentFileData ) ;
7170
7271 fs . appendFile ( filename , s , common . mustSucceed ( ( ) => {
@@ -79,7 +78,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
7978
8079// Test that appends data to a non-empty file (promise API).
8180{
82- const filename = join ( tmpdir . path , 'append-non-empty-promise.txt' ) ;
81+ const filename = tmpdir . resolve ( 'append-non-empty-promise.txt' ) ;
8382 fs . writeFileSync ( filename , currentFileData ) ;
8483
8584 fs . promises . appendFile ( filename , s )
@@ -93,7 +92,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
9392
9493// Test that appendFile accepts buffers (callback API).
9594{
96- const filename = join ( tmpdir . path , 'append-buffer.txt' ) ;
95+ const filename = tmpdir . resolve ( 'append-buffer.txt' ) ;
9796 fs . writeFileSync ( filename , currentFileData ) ;
9897
9998 const buf = Buffer . from ( s , 'utf8' ) ;
@@ -107,7 +106,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
107106
108107// Test that appendFile accepts buffers (promises API).
109108{
110- const filename = join ( tmpdir . path , 'append-buffer-promises.txt' ) ;
109+ const filename = tmpdir . resolve ( 'append-buffer-promises.txt' ) ;
111110 fs . writeFileSync ( filename , currentFileData ) ;
112111
113112 const buf = Buffer . from ( s , 'utf8' ) ;
@@ -126,7 +125,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
126125 code : 'ERR_INVALID_ARG_TYPE' ,
127126 message : / " d a t a " | " b u f f e r " /
128127 } ;
129- const filename = join ( tmpdir . path , 'append-invalid-data.txt' ) ;
128+ const filename = tmpdir . resolve ( 'append-invalid-data.txt' ) ;
130129
131130 assert . throws (
132131 ( ) => fs . appendFile ( filename , data , common . mustNotCall ( ) ) ,
@@ -154,7 +153,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
154153
155154// Test that appendFile accepts file descriptors (callback API).
156155{
157- const filename = join ( tmpdir . path , 'append-descriptors.txt' ) ;
156+ const filename = tmpdir . resolve ( 'append-descriptors.txt' ) ;
158157 fs . writeFileSync ( filename , currentFileData ) ;
159158
160159 fs . open ( filename , 'a+' , common . mustSucceed ( ( fd ) => {
@@ -171,7 +170,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
171170
172171// Test that appendFile accepts file descriptors (promises API).
173172{
174- const filename = join ( tmpdir . path , 'append-descriptors-promises.txt' ) ;
173+ const filename = tmpdir . resolve ( 'append-descriptors-promises.txt' ) ;
175174 fs . writeFileSync ( filename , currentFileData ) ;
176175
177176 let fd ;
@@ -190,5 +189,5 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
190189}
191190
192191assert . throws (
193- ( ) => fs . appendFile ( join ( tmpdir . path , 'append6.txt' ) , console . log ) ,
192+ ( ) => fs . appendFile ( tmpdir . resolve ( 'append6.txt' ) , console . log ) ,
194193 { code : 'ERR_INVALID_ARG_TYPE' } ) ;
0 commit comments