Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use sys_traits #70

Merged
merged 12 commits into from
Dec 27, 2024
Merged
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 @@ -65,7 +65,7 @@ jobs:
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install Deno
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@v2
with:
deno-version: canary

Expand Down
134 changes: 120 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ members = [
"rs_lib",
]

[workspace.dependencies]
sys_traits = "0.1.0"

[profile.release]
codegen-units = 1
incremental = true
Expand Down
28 changes: 5 additions & 23 deletions deno_dir.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 2018-2024 the Deno authors. MIT license.

import { isAbsolute, join, normalize, resolve } from "@std/path";
import { isAbsolute, join, resolve } from "@std/path";
import { DiskCache } from "./disk_cache.ts";
import { cacheDir, homeDir } from "./dirs.ts";
import { HttpCache } from "./http_cache.ts";
import { assert } from "./util.ts";
import { instantiate } from "./lib/deno_cache_dir.generated.js";

export class DenoDir {
readonly root: string;
Expand Down Expand Up @@ -40,29 +40,11 @@ export class DenoDir {
root: string | URL | undefined,
): string | undefined {
if (root) {
root = resolvePathOrUrl(root);
return resolvePathOrUrl(root);
} else {
Deno.permissions.request({ name: "env", variable: "DENO_DIR" });
const dd = Deno.env.get("DENO_DIR");
if (dd) {
if (!isAbsolute(dd)) {
root = normalize(join(Deno.cwd(), dd));
} else {
root = dd;
}
} else {
const cd = cacheDir();
if (cd) {
root = join(cd, "deno");
} else {
const hd = homeDir();
if (hd) {
root = join(hd, ".deno");
}
}
}
const instance = instantiate();
return instance.resolve_deno_dir();
}
return root;
}
}

Expand Down
36 changes: 0 additions & 36 deletions dirs.ts

This file was deleted.

6 changes: 6 additions & 0 deletions lib/deno_cache_dir.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface InstantiateResult {
instance: WebAssembly.Instance;
exports: {
url_to_filename: typeof url_to_filename;
resolve_deno_dir: typeof resolve_deno_dir;
GlobalHttpCache : typeof GlobalHttpCache ;
LocalHttpCache : typeof LocalHttpCache
};
Expand All @@ -30,6 +31,11 @@ export function instantiateWithInstance(): InstantiateResult;
*/
export function url_to_filename(url: string): string;
/**
* @param {string | undefined} [maybe_custom_root]
* @returns {string}
*/
export function resolve_deno_dir(maybe_custom_root?: string): string;
/**
*/
export class GlobalHttpCache {
free(): void;
Expand Down
Loading
Loading