summaryrefslogtreecommitdiff
path: root/cli/npm/resolvers/global.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-05-10 20:06:59 -0400
committerGitHub <noreply@github.com>2023-05-10 20:06:59 -0400
commit28aa489de9cd4f995ec2fc02e2c9d224e89f4c01 (patch)
treeb316937a47fe9c8f9f6768bc13b9a686c07cf42f /cli/npm/resolvers/global.rs
parent5fd74bfa1c5ed514c3e19fdb2e8590fe251d3ee6 (diff)
feat(compile): unstable npm and node specifier support (#19005)
This is the initial support for npm and node specifiers in `deno compile`. The npm packages are included in the binary and read from it via a virtual file system. This also supports the `--node-modules-dir` flag, dependencies specified in a package.json, and npm binary commands (ex. `deno compile --unstable npm:cowsay`) Closes #16632
Diffstat (limited to 'cli/npm/resolvers/global.rs')
-rw-r--r--cli/npm/resolvers/global.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/cli/npm/resolvers/global.rs b/cli/npm/resolvers/global.rs
index 79df16187..fe8764b0c 100644
--- a/cli/npm/resolvers/global.rs
+++ b/cli/npm/resolvers/global.rs
@@ -14,6 +14,7 @@ use deno_npm::resolution::PackageNotFoundFromReferrerError;
use deno_npm::NpmPackageCacheFolderId;
use deno_npm::NpmPackageId;
use deno_npm::NpmResolutionPackage;
+use deno_runtime::deno_fs::FileSystem;
use deno_runtime::deno_node::NodePermissions;
use deno_runtime::deno_node::NodeResolutionMode;
@@ -28,6 +29,7 @@ use super::common::NpmPackageFsResolver;
/// Resolves packages from the global npm cache.
#[derive(Debug)]
pub struct GlobalNpmPackageResolver {
+ fs: Arc<dyn FileSystem>,
cache: Arc<NpmCache>,
resolution: Arc<NpmResolution>,
registry_url: Url,
@@ -35,11 +37,13 @@ pub struct GlobalNpmPackageResolver {
impl GlobalNpmPackageResolver {
pub fn new(
+ fs: Arc<dyn FileSystem>,
cache: Arc<NpmCache>,
registry_url: Url,
resolution: Arc<NpmResolution>,
) -> Self {
Self {
+ fs,
cache,
resolution,
registry_url,
@@ -130,7 +134,7 @@ impl NpmPackageFsResolver for GlobalNpmPackageResolver {
path: &Path,
) -> Result<(), AnyError> {
let registry_path = self.cache.registry_folder(&self.registry_url);
- ensure_registry_read_permission(permissions, &registry_path, path)
+ ensure_registry_read_permission(&self.fs, permissions, &registry_path, path)
}
}