summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/args/mod.rs2
-rw-r--r--cli/lsp/config.rs2
-rw-r--r--tests/specs/workspaces/auto_install_pkg_json_member_only/__test__.jsonc4
-rw-r--r--tests/specs/workspaces/auto_install_pkg_json_member_only/deno.json4
-rw-r--r--tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.out3
-rw-r--r--tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.ts3
-rw-r--r--tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/package.json5
7 files changed, 21 insertions, 2 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index a7e75745a..be8eccd6c 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -1740,7 +1740,7 @@ fn resolve_node_modules_folder(
return Ok(None);
} else if let Some(state) = &*NPM_PROCESS_STATE {
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);
if let Ok(deno_dir) = deno_dir_provider.get_or_create() {
// `deno_dir.root` can be symlink in macOS
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs
index 854e55250..d204dce64 100644
--- a/cli/lsp/config.rs
+++ b/cli/lsp/config.rs
@@ -1393,7 +1393,7 @@ impl ConfigData {
.unwrap_or_default();
let byonm = match node_modules_dir {
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 {
lsp_log!(" Enabled 'bring your own node_modules'.");
diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/__test__.jsonc b/tests/specs/workspaces/auto_install_pkg_json_member_only/__test__.jsonc
new file mode 100644
index 000000000..15c10d573
--- /dev/null
+++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/__test__.jsonc
@@ -0,0 +1,4 @@
+{
+ "args": "run -A pkg_json/main.ts",
+ "output": "pkg_json/main.out"
+}
diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/deno.json b/tests/specs/workspaces/auto_install_pkg_json_member_only/deno.json
new file mode 100644
index 000000000..0c1e5e08e
--- /dev/null
+++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/deno.json
@@ -0,0 +1,4 @@
+{
+ "lock": false,
+ "workspace": ["pkg_json"]
+}
diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.out b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.out
new file mode 100644
index 000000000..392591008
--- /dev/null
+++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.out
@@ -0,0 +1,3 @@
+Download http://localhost:4260/chalk
+Download http://localhost:4260/chalk/chalk-5.0.1.tgz
+Hi
diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.ts b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.ts
new file mode 100644
index 000000000..009e10e7e
--- /dev/null
+++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.ts
@@ -0,0 +1,3 @@
+import chalk from "chalk";
+
+console.log(chalk.green("Hi"));
diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/package.json b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/package.json
new file mode 100644
index 000000000..c58c3ac3c
--- /dev/null
+++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "chalk": "*"
+ }
+}