23
23
const common = require ( '../common' ) ;
24
24
const assert = require ( 'assert' ) ;
25
25
const fs = require ( 'fs' ) ;
26
- const join = require ( 'path' ) . join ;
27
26
28
27
const tmpdir = require ( '../common/tmpdir' ) ;
29
28
@@ -43,7 +42,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
43
42
44
43
// Test that empty file will be created and have content added (callback API).
45
44
{
46
- const filename = join ( tmpdir . path , 'append.txt' ) ;
45
+ const filename = tmpdir . resolve ( 'append.txt' ) ;
47
46
48
47
fs . appendFile ( filename , s , common . mustSucceed ( ( ) => {
49
48
fs . readFile ( filename , common . mustSucceed ( ( buffer ) => {
@@ -54,7 +53,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
54
53
55
54
// Test that empty file will be created and have content added (promise API).
56
55
{
57
- const filename = join ( tmpdir . path , 'append-promise.txt' ) ;
56
+ const filename = tmpdir . resolve ( 'append-promise.txt' ) ;
58
57
59
58
fs . promises . appendFile ( filename , s )
60
59
. then ( common . mustCall ( ( ) => fs . promises . readFile ( filename ) ) )
@@ -66,7 +65,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
66
65
67
66
// Test that appends data to a non-empty file (callback API).
68
67
{
69
- const filename = join ( tmpdir . path , 'append-non-empty.txt' ) ;
68
+ const filename = tmpdir . resolve ( 'append-non-empty.txt' ) ;
70
69
fs . writeFileSync ( filename , currentFileData ) ;
71
70
72
71
fs . appendFile ( filename , s , common . mustSucceed ( ( ) => {
@@ -79,7 +78,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
79
78
80
79
// Test that appends data to a non-empty file (promise API).
81
80
{
82
- const filename = join ( tmpdir . path , 'append-non-empty-promise.txt' ) ;
81
+ const filename = tmpdir . resolve ( 'append-non-empty-promise.txt' ) ;
83
82
fs . writeFileSync ( filename , currentFileData ) ;
84
83
85
84
fs . promises . appendFile ( filename , s )
@@ -93,7 +92,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
93
92
94
93
// Test that appendFile accepts buffers (callback API).
95
94
{
96
- const filename = join ( tmpdir . path , 'append-buffer.txt' ) ;
95
+ const filename = tmpdir . resolve ( 'append-buffer.txt' ) ;
97
96
fs . writeFileSync ( filename , currentFileData ) ;
98
97
99
98
const buf = Buffer . from ( s , 'utf8' ) ;
@@ -107,7 +106,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
107
106
108
107
// Test that appendFile accepts buffers (promises API).
109
108
{
110
- const filename = join ( tmpdir . path , 'append-buffer-promises.txt' ) ;
109
+ const filename = tmpdir . resolve ( 'append-buffer-promises.txt' ) ;
111
110
fs . writeFileSync ( filename , currentFileData ) ;
112
111
113
112
const buf = Buffer . from ( s , 'utf8' ) ;
@@ -126,7 +125,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
126
125
code : 'ERR_INVALID_ARG_TYPE' ,
127
126
message : / " d a t a " | " b u f f e r " /
128
127
} ;
129
- const filename = join ( tmpdir . path , 'append-invalid-data.txt' ) ;
128
+ const filename = tmpdir . resolve ( 'append-invalid-data.txt' ) ;
130
129
131
130
assert . throws (
132
131
( ) => fs . appendFile ( filename , data , common . mustNotCall ( ) ) ,
@@ -154,7 +153,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
154
153
155
154
// Test that appendFile accepts file descriptors (callback API).
156
155
{
157
- const filename = join ( tmpdir . path , 'append-descriptors.txt' ) ;
156
+ const filename = tmpdir . resolve ( 'append-descriptors.txt' ) ;
158
157
fs . writeFileSync ( filename , currentFileData ) ;
159
158
160
159
fs . open ( filename , 'a+' , common . mustSucceed ( ( fd ) => {
@@ -171,7 +170,7 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
171
170
172
171
// Test that appendFile accepts file descriptors (promises API).
173
172
{
174
- const filename = join ( tmpdir . path , 'append-descriptors-promises.txt' ) ;
173
+ const filename = tmpdir . resolve ( 'append-descriptors-promises.txt' ) ;
175
174
fs . writeFileSync ( filename , currentFileData ) ;
176
175
177
176
let fd ;
@@ -190,5 +189,5 @@ const throwNextTick = (e) => { process.nextTick(() => { throw e; }); };
190
189
}
191
190
192
191
assert . throws (
193
- ( ) => fs . appendFile ( join ( tmpdir . path , 'append6.txt' ) , console . log ) ,
192
+ ( ) => fs . appendFile ( tmpdir . resolve ( 'append6.txt' ) , console . log ) ,
194
193
{ code : 'ERR_INVALID_ARG_TYPE' } ) ;
0 commit comments