Skip to content

Commit

Permalink
fix: make file writable after copy to cache (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen authored Jan 18, 2023
1 parent 7e85fa9 commit dcda7cd
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
tests:
name: ${{ matrix.kind }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
timeout-minutes: 5
strategy:
matrix:
os: [macOS-latest, windows-latest, ubuntu-latest]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2022 the denosaurs team
Copyright (c) 2020-2023 the denosaurs team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ Pull request, issues and feedback are very welcome. Code style is formatted with

### Licence

Copyright 2020-2022, the denosaurs team. All rights reserved. MIT license.
Copyright 2020-2023, the denosaurs team. All rights reserved. MIT license.
8 changes: 4 additions & 4 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {
normalize,
resolve,
toFileUrl,
} from "https://deno.land/std@0.157.0/path/mod.ts";
export { ensureDir } from "https://deno.land/std@0.157.0/fs/mod.ts";
export { encode as hex } from "https://deno.land/std@0.157.0/encoding/hex.ts";
export * as colors from "https://deno.land/std@0.157.0/fmt/colors.ts";
} from "https://deno.land/std@0.173.0/path/mod.ts";
export { ensureDir } from "https://deno.land/std@0.173.0/fs/mod.ts";
export { encode as hex } from "https://deno.land/std@0.173.0/encoding/hex.ts";
export * as colors from "https://deno.land/std@0.173.0/fmt/colors.ts";
3 changes: 3 additions & 0 deletions download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ export async function download(options: FetchOptions): Promise<string> {
case "file:": {
console.log(`${colors.green("Copying")} ${url}`);
await Deno.copyFile(fromFileUrl(url), cacheFilePath);
if (Deno.build.os !== "windows") {
await Deno.chmod(cacheFilePath, 0o644);
}
break;
}

Expand Down
4 changes: 2 additions & 2 deletions test_deps.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "https://deno.land/std@0.157.0/testing/asserts.ts";
export * from "https://deno.land/std@0.157.0/path/mod.ts";
export * from "https://deno.land/std@0.173.0/testing/asserts.ts";
export * from "https://deno.land/std@0.173.0/path/mod.ts";
5 changes: 0 additions & 5 deletions util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ export async function isFile(filePath: string): Promise<boolean> {
export function homeDir(): string | undefined {
switch (Deno.build.os) {
case "windows":
Deno.permissions.request({ name: "env", variable: "USERPROFILE" });
return Deno.env.get("USERPROFILE");
case "linux":
case "darwin":
Deno.permissions.request({ name: "env", variable: "HOME" });
return Deno.env.get("HOME");
default:
throw Error("unreachable");
Expand All @@ -97,7 +95,6 @@ export function cacheDir(): string | undefined {
return join(home, "Library/Caches");
}
} else if (Deno.build.os === "linux") {
Deno.permissions.request({ name: "env", variable: "XDG_CACHE_HOME" });
const cacheHome = Deno.env.get("XDG_CACHE_HOME");
if (cacheHome) {
return cacheHome;
Expand All @@ -108,13 +105,11 @@ export function cacheDir(): string | undefined {
}
}
} else {
Deno.permissions.request({ name: "env", variable: "LOCALAPPDATA" });
return Deno.env.get("LOCALAPPDATA");
}
}

export function denoCacheDir() {
Deno.permissions.request({ name: "env", variable: "DENO_DIR" });
const dd = Deno.env.get("DENO_DIR");
let root;
if (dd) {
Expand Down

0 comments on commit dcda7cd

Please sign in to comment.