Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denolib/setup-deno@v2
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- run: deno fmt --check .
Expand Down
18 changes: 15 additions & 3 deletions pkgm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ const parsedArgs = parseArgs(Deno.args, {
v: "version",
h: "help",
p: "pin",
f: "force",
},
boolean: ["help", "version", "pin"],
boolean: ["help", "version", "pin", "force"],
});

if (parsedArgs.help || parsedArgs._[0] == "help") {
Expand Down Expand Up @@ -506,8 +507,19 @@ function expand_runtime_env(
}

function symlink_with_overwrite(src: string, dst: string) {
if (existsSync(dst) && Deno.lstatSync(dst).isSymlink) {
Deno.removeSync(dst);
try {
const stat = Deno.lstatSync(dst);
if (stat.isSymlink) {
Deno.removeSync(dst);
} else if (parsedArgs.force) {
Deno.removeSync(dst);
} else {
throw new Error(
`refusing to overwrite non-symlink at: ${dst} (use --force to override)`,
);
}
} catch (e) {
if (!(e instanceof Deno.errors.NotFound)) throw e;
}
Deno.symlinkSync(src, dst);
}
Expand Down
Loading