fix(installer): narrow error handling in copy() and fix test interdependency
- copy() overwrite:false catch now only ignores ENOENT/ENOTDIR, consistent with pathExists(); permission errors propagate correctly - 'copy creates parent directories' test creates its own fixture instead of depending on state from a previous test
This commit is contained in:
parent
a12d5d03b5
commit
2771dd76b8
|
|
@ -270,10 +270,11 @@ async function runTests() {
|
|||
});
|
||||
|
||||
await asyncTest('copy creates parent directories for dest', async () => {
|
||||
const src = path.join(TMP, 'copy-file-src.txt');
|
||||
const src = path.join(TMP, 'copy-mkdir-src.txt');
|
||||
nativeFs.writeFileSync(src, 'copy mkdir');
|
||||
const dest = path.join(TMP, 'copy-deep', 'nested', 'dest.txt');
|
||||
await fs.copy(src, dest);
|
||||
assertEqual(nativeFs.readFileSync(dest, 'utf8'), 'copy file', 'copy with mkdir content mismatch');
|
||||
assertEqual(nativeFs.readFileSync(dest, 'utf8'), 'copy mkdir', 'copy with mkdir content mismatch');
|
||||
});
|
||||
|
||||
await asyncTest('copy copies a directory recursively', async () => {
|
||||
|
|
|
|||
|
|
@ -115,7 +115,10 @@ module.exports.copy = async function copy(src, dest, options = {}) {
|
|||
try {
|
||||
await fsp.access(dest);
|
||||
return; // dest exists, skip
|
||||
} catch {
|
||||
} catch (error) {
|
||||
if (error && error.code !== 'ENOENT' && error.code !== 'ENOTDIR') {
|
||||
throw error;
|
||||
}
|
||||
// dest doesn't exist, proceed
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue