feat(npm): functionality to support child_process.fork (#15891)

This commit is contained in:
David Sherret 2022-09-28 13:04:16 -04:00 committed by GitHub
parent 23125b275f
commit d677ba67f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 232 additions and 21 deletions

View file

@ -13,6 +13,7 @@ use deno_core::futures::FutureExt;
use deno_core::url::Url;
use crate::npm::resolution::NpmResolution;
use crate::npm::resolution::NpmResolutionSnapshot;
use crate::npm::resolvers::common::cache_packages;
use crate::npm::NpmCache;
use crate::npm::NpmPackageId;
@ -31,9 +32,13 @@ pub struct GlobalNpmPackageResolver {
}
impl GlobalNpmPackageResolver {
pub fn new(cache: NpmCache, api: NpmRegistryApi) -> Self {
pub fn new(
cache: NpmCache,
api: NpmRegistryApi,
initial_snapshot: Option<NpmResolutionSnapshot>,
) -> Self {
let registry_url = api.base_url().to_owned();
let resolution = Arc::new(NpmResolution::new(api));
let resolution = Arc::new(NpmResolution::new(api, initial_snapshot));
Self {
cache,
@ -105,4 +110,8 @@ impl InnerNpmPackageResolver for GlobalNpmPackageResolver {
let registry_path = self.cache.registry_folder(&self.registry_url);
ensure_registry_read_permission(&registry_path, path)
}
fn snapshot(&self) -> NpmResolutionSnapshot {
self.resolution.snapshot()
}
}