@@ -85,6 +85,7 @@ function getValidatedPath(fileURLOrPath) {
85
85
86
86
async function cpFn ( src , dest , opts ) {
87
87
// Warn about using preserveTimestamps on 32-bit node
88
+ // istanbul ignore next
88
89
if ( opts . preserveTimestamps && process . arch === 'ia32' ) {
89
90
const warning = 'Using the preserveTimestamps option in 32-bit ' +
90
91
'node is not recommended' ;
@@ -153,7 +154,11 @@ function getStats(src, dest, opts) {
153
154
return Promise . all ( [
154
155
statFunc ( src ) ,
155
156
statFunc ( dest ) . catch ( ( err ) => {
156
- if ( err . code === 'ENOENT' ) return null ;
157
+ // istanbul ignore next: unsure how to cover.
158
+ if ( err . code === 'ENOENT' ) {
159
+ return null
160
+ }
161
+ // istanbul ignore next: unsure how to cover.
157
162
throw err ;
158
163
} ) ,
159
164
] ) ;
@@ -170,6 +175,7 @@ async function checkParentDir(destStat, src, dest, opts) {
170
175
function pathExists ( dest ) {
171
176
return stat ( dest ) . then (
172
177
( ) => true ,
178
+ // istanbul ignore next: not sure when this would occur
173
179
( err ) => ( err . code === 'ENOENT' ? false : Promise . reject ( err ) ) ) ;
174
180
}
175
181
@@ -187,7 +193,9 @@ async function checkParentPaths(src, srcStat, dest) {
187
193
try {
188
194
destStat = await stat ( destParent , { bigint : true } ) ;
189
195
} catch ( err ) {
196
+ // istanbul ignore else: not sure when this would occur
190
197
if ( err . code === 'ENOENT' ) return ;
198
+ // istanbul ignore next: not sure when this would occur
191
199
throw err ;
192
200
}
193
201
if ( areIdentical ( srcStat , destStat ) ) {
@@ -227,6 +235,7 @@ function startCopy(destStat, src, dest, opts) {
227
235
async function getStatsForCopy ( destStat , src , dest , opts ) {
228
236
const statFn = opts . dereference ? stat : lstat ;
229
237
const srcStat = await statFn ( src ) ;
238
+ // istanbul ignore else: can't portably test FIFO
230
239
if ( srcStat . isDirectory ( ) && opts . recursive ) {
231
240
return onDir ( srcStat , destStat , src , dest , opts ) ;
232
241
} else if ( srcStat . isDirectory ( ) ) {
@@ -249,14 +258,15 @@ async function getStatsForCopy(destStat, src, dest, opts) {
249
258
syscall : 'cp' ,
250
259
errno : EINVAL ,
251
260
} ) ;
252
- } else if ( srcStat . isFIFO ( ) ) {
261
+ } else if ( srcStat . isFIFO ( ) ) {
253
262
throw new ERR_FS_CP_FIFO_PIPE ( {
254
263
message : `cannot copy a FIFO pipe: ${ dest } ` ,
255
264
path : dest ,
256
265
syscall : 'cp' ,
257
266
errno : EINVAL ,
258
267
} ) ;
259
268
}
269
+ // istanbul ignore next: should be unreachable
260
270
throw new ERR_FS_CP_UNKNOWN ( {
261
271
message : `cannot copy an unknown file type: ${ dest } ` ,
262
272
path : dest ,
@@ -365,9 +375,11 @@ async function onLink(destStat, src, dest) {
365
375
// Dest exists and is a regular file or directory,
366
376
// Windows may throw UNKNOWN error. If dest already exists,
367
377
// fs throws error anyway, so no need to guard against it here.
378
+ // istanbul ignore next: can only test on windows
368
379
if ( err . code === 'EINVAL' || err . code === 'UNKNOWN' ) {
369
380
return symlink ( resolvedSrc , dest ) ;
370
381
}
382
+ // istanbul ignore next: should not be possible
371
383
throw err ;
372
384
}
373
385
if ( ! isAbsolute ( resolvedDest ) ) {
0 commit comments