Skip to content

Commit

Permalink
fix: return original error when can't rename overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Dec 25, 2024
1 parent 115cfc4 commit bc151c1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ async function forceSymlink (
warn = `Symlink wanted name was occupied by directory or file. Old entity removed: "${parentDir}${pathLib.sep}{${pathLib.basename(path)}".`
} else {
const ignore = `.ignored_${pathLib.basename(path)}`
await renameOverwrite(path, pathLib.join(parentDir, ignore))
try {
await renameOverwrite(path, pathLib.join(parentDir, ignore))
} catch (error) {
if (util.types.isNativeError(error) && 'code' in error && error.code === 'ENOENT') {
throw initialErr
}
throw error
}

warn = `Symlink wanted name was occupied by directory or file. Old entity moved: "${parentDir}${pathLib.sep}{${pathLib.basename(path)} => ${ignore}".`
}

Expand Down Expand Up @@ -185,7 +193,14 @@ function forceSymlinkSync (
warn = `Symlink wanted name was occupied by directory or file. Old entity removed: "${parentDir}${pathLib.sep}{${pathLib.basename(path)}".`
} else {
const ignore = `.ignored_${pathLib.basename(path)}`
renameOverwrite.sync(path, pathLib.join(parentDir, ignore))
try {
renameOverwrite.sync(path, pathLib.join(parentDir, ignore))
} catch (error) {
if (util.types.isNativeError(error) && 'code' in error && error.code === 'ENOENT') {
throw initialErr
}
throw error
}
warn = `Symlink wanted name was occupied by directory or file. Old entity moved: "${parentDir}${pathLib.sep}{${pathLib.basename(path)} => ${ignore}".`
}

Expand Down

0 comments on commit bc151c1

Please sign in to comment.