1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix: only enable byonm if workspace root has pkg json (#25379)

Closes #25355
This commit is contained in:
David Sherret 2024-09-03 11:18:37 +02:00 committed by GitHub
parent b9b4b0dd67
commit b5695d02df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 21 additions and 2 deletions

View file

@ -1740,7 +1740,7 @@ fn resolve_node_modules_folder(
return Ok(None); return Ok(None);
} else if let Some(state) = &*NPM_PROCESS_STATE { } else if let Some(state) = &*NPM_PROCESS_STATE {
return Ok(state.local_node_modules_path.as_ref().map(PathBuf::from)); return Ok(state.local_node_modules_path.as_ref().map(PathBuf::from));
} else if workspace.package_jsons().next().is_some() { } else if root_folder.pkg_json.is_some() {
let node_modules_dir = resolve_from_root(root_folder, cwd); let node_modules_dir = resolve_from_root(root_folder, cwd);
if let Ok(deno_dir) = deno_dir_provider.get_or_create() { if let Ok(deno_dir) = deno_dir_provider.get_or_create() {
// `deno_dir.root` can be symlink in macOS // `deno_dir.root` can be symlink in macOS

View file

@ -1393,7 +1393,7 @@ impl ConfigData {
.unwrap_or_default(); .unwrap_or_default();
let byonm = match node_modules_dir { let byonm = match node_modules_dir {
Some(mode) => mode == NodeModulesDirMode::Manual, Some(mode) => mode == NodeModulesDirMode::Manual,
None => member_dir.workspace.package_jsons().next().is_some(), None => member_dir.workspace.root_pkg_json().is_some(),
}; };
if byonm { if byonm {
lsp_log!(" Enabled 'bring your own node_modules'."); lsp_log!(" Enabled 'bring your own node_modules'.");

View file

@ -0,0 +1,4 @@
{
"args": "run -A pkg_json/main.ts",
"output": "pkg_json/main.out"
}

View file

@ -0,0 +1,4 @@
{
"lock": false,
"workspace": ["pkg_json"]
}

View file

@ -0,0 +1,3 @@
Download http://localhost:4260/chalk
Download http://localhost:4260/chalk/chalk-5.0.1.tgz
Hi

View file

@ -0,0 +1,3 @@
import chalk from "chalk";
console.log(chalk.green("Hi"));

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"chalk": "*"
}
}