From dcda7cdef3811b23718b06e193e932b8de4e8d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6green?= Date: Wed, 18 Jan 2023 19:13:24 +0100 Subject: [PATCH] fix: make file writable after copy to cache (#22) --- .github/workflows/deno.yml | 2 +- LICENSE | 2 +- README.md | 2 +- deps.ts | 8 ++++---- download.ts | 3 +++ test_deps.ts | 4 ++-- util.ts | 5 ----- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml index d940b23..6c6d5ba 100644 --- a/.github/workflows/deno.yml +++ b/.github/workflows/deno.yml @@ -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] diff --git a/LICENSE b/LICENSE index 992af30..41e1668 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 587be21..a39d88d 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/deps.ts b/deps.ts index 97341be..ea7552a 100644 --- a/deps.ts +++ b/deps.ts @@ -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"; diff --git a/download.ts b/download.ts index 7514f20..121c7e9 100644 --- a/download.ts +++ b/download.ts @@ -255,6 +255,9 @@ export async function download(options: FetchOptions): Promise { 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; } diff --git a/test_deps.ts b/test_deps.ts index d5bf551..45daa54 100644 --- a/test_deps.ts +++ b/test_deps.ts @@ -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"; diff --git a/util.ts b/util.ts index cca5b5f..aa831e1 100644 --- a/util.ts +++ b/util.ts @@ -79,11 +79,9 @@ export async function isFile(filePath: string): Promise { 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"); @@ -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; @@ -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) {