mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
refactor(cli): clean up clones (#17268)
This commit is contained in:
parent
14c4c8f934
commit
dd05c3b70d
5 changed files with 12 additions and 12 deletions
|
@ -112,7 +112,7 @@ impl Lockfile {
|
||||||
None => match maybe_config_file {
|
None => match maybe_config_file {
|
||||||
Some(config_file) => {
|
Some(config_file) => {
|
||||||
if config_file.specifier.scheme() == "file" {
|
if config_file.specifier.scheme() == "file" {
|
||||||
match config_file.clone().to_lock_config()? {
|
match config_file.to_lock_config()? {
|
||||||
Some(LockConfig::Bool(lock)) if !lock => {
|
Some(LockConfig::Bool(lock)) if !lock => {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
|
@ -597,7 +597,7 @@ pub fn error_for_any_npm_specifier(
|
||||||
.specifiers()
|
.specifiers()
|
||||||
.filter_map(|(_, r)| match r {
|
.filter_map(|(_, r)| match r {
|
||||||
Ok((specifier, kind, _)) if kind == deno_graph::ModuleKind::External => {
|
Ok((specifier, kind, _)) if kind == deno_graph::ModuleKind::External => {
|
||||||
Some(specifier.clone())
|
Some(specifier)
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
|
|
@ -239,7 +239,7 @@ impl ProcState {
|
||||||
.resolve_local_node_modules_folder()
|
.resolve_local_node_modules_folder()
|
||||||
.with_context(|| "Resolving local node_modules folder.")?,
|
.with_context(|| "Resolving local node_modules folder.")?,
|
||||||
);
|
);
|
||||||
if let Some(lockfile) = maybe_lockfile.clone() {
|
if let Some(lockfile) = maybe_lockfile {
|
||||||
npm_resolver
|
npm_resolver
|
||||||
.add_lockfile_and_maybe_regenerate_snapshot(lockfile)
|
.add_lockfile_and_maybe_regenerate_snapshot(lockfile)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -328,8 +328,8 @@ impl ProcState {
|
||||||
let mut cache = cache::FetchCacher::new(
|
let mut cache = cache::FetchCacher::new(
|
||||||
self.emit_cache.clone(),
|
self.emit_cache.clone(),
|
||||||
self.file_fetcher.clone(),
|
self.file_fetcher.clone(),
|
||||||
root_permissions.clone(),
|
root_permissions,
|
||||||
dynamic_permissions.clone(),
|
dynamic_permissions,
|
||||||
);
|
);
|
||||||
let maybe_imports = self.options.to_maybe_imports()?;
|
let maybe_imports = self.options.to_maybe_imports()?;
|
||||||
let maybe_resolver =
|
let maybe_resolver =
|
||||||
|
|
|
@ -289,7 +289,7 @@ pub async fn run(
|
||||||
user_agent: version::get_user_agent(),
|
user_agent: version::get_user_agent(),
|
||||||
inspect: ps.options.is_inspecting(),
|
inspect: ps.options.is_inspecting(),
|
||||||
},
|
},
|
||||||
extensions: ops::cli_exts(ps.clone()),
|
extensions: ops::cli_exts(ps),
|
||||||
extensions_with_js: vec![],
|
extensions_with_js: vec![],
|
||||||
startup_snapshot: Some(crate::js::deno_isolate_init()),
|
startup_snapshot: Some(crate::js::deno_isolate_init()),
|
||||||
unsafely_ignore_certificate_errors: metadata
|
unsafely_ignore_certificate_errors: metadata
|
||||||
|
|
|
@ -510,28 +510,28 @@ fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
|
||||||
let specifier = if let Some(remapped_specifier) =
|
let specifier = if let Some(remapped_specifier) =
|
||||||
state.remapped_specifiers.get(&v.specifier)
|
state.remapped_specifiers.get(&v.specifier)
|
||||||
{
|
{
|
||||||
remapped_specifier.clone()
|
remapped_specifier
|
||||||
} else if let Some(remapped_specifier) = state.root_map.get(&v.specifier) {
|
} else if let Some(remapped_specifier) = state.root_map.get(&v.specifier) {
|
||||||
remapped_specifier.clone()
|
remapped_specifier
|
||||||
} else {
|
} else {
|
||||||
specifier
|
&specifier
|
||||||
};
|
};
|
||||||
let maybe_source = if let Some(ModuleEntry::Module {
|
let maybe_source = if let Some(ModuleEntry::Module {
|
||||||
code,
|
code,
|
||||||
media_type: mt,
|
media_type: mt,
|
||||||
..
|
..
|
||||||
}) =
|
}) =
|
||||||
graph_data.get(&graph_data.follow_redirect(&specifier))
|
graph_data.get(&graph_data.follow_redirect(specifier))
|
||||||
{
|
{
|
||||||
media_type = *mt;
|
media_type = *mt;
|
||||||
Some(Cow::Borrowed(code as &str))
|
Some(Cow::Borrowed(code as &str))
|
||||||
} else if state
|
} else if state
|
||||||
.maybe_npm_resolver
|
.maybe_npm_resolver
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|resolver| resolver.in_npm_package(&specifier))
|
.map(|resolver| resolver.in_npm_package(specifier))
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
media_type = MediaType::from(&specifier);
|
media_type = MediaType::from(specifier);
|
||||||
let file_path = specifier.to_file_path().unwrap();
|
let file_path = specifier.to_file_path().unwrap();
|
||||||
let code = std::fs::read_to_string(&file_path)
|
let code = std::fs::read_to_string(&file_path)
|
||||||
.with_context(|| format!("Unable to load {}", file_path.display()))?;
|
.with_context(|| format!("Unable to load {}", file_path.display()))?;
|
||||||
|
|
Loading…
Reference in a new issue