Skip to content

Commit

Permalink
fix(install): duplicate dependencies in package.json (denoland#26128)
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister authored Oct 10, 2024
1 parent 66929de commit ccdbeb4
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cli/tools/registry/pm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ impl NpmConfig {
fn add(&mut self, selected: SelectedPackage, dev: bool) {
let (name, version) = package_json_dependency_entry(selected);
if dev {
self.dependencies.swap_remove(&name);
self.dev_dependencies.insert(name, version);
} else {
self.dev_dependencies.swap_remove(&name);
self.dependencies.insert(name, version);
}
}
Expand Down
16 changes: 16 additions & 0 deletions tests/specs/install/install_add_dep_existing/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"tempDir": true,
"steps": [
{
"args": "install npm:@denotest/esm-basic",
"output": "install.out"
},
{
"args": [
"eval",
"console.log(Deno.readTextFileSync('package.json').trim())"
],
"output": "package.json.out"
}
]
}
4 changes: 4 additions & 0 deletions tests/specs/install/install_add_dep_existing/install.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add npm:@denotest/[email protected]
Download http://localhost:4260/@denotest/esm-basic
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
Initialize @denotest/[email protected]
3 changes: 3 additions & 0 deletions tests/specs/install/install_add_dep_existing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"devDependencies": { "@denotest/esm-basic": "^1.0.0" }
}
5 changes: 5 additions & 0 deletions tests/specs/install/install_add_dep_existing/package.json.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/esm-basic": "^1.0.0"
}
}
16 changes: 16 additions & 0 deletions tests/specs/install/install_add_dev_existing/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"tempDir": true,
"steps": [
{
"args": "install --dev npm:@denotest/esm-basic",
"output": "install.out"
},
{
"args": [
"eval",
"console.log(Deno.readTextFileSync('package.json').trim())"
],
"output": "package.json.out"
}
]
}
4 changes: 4 additions & 0 deletions tests/specs/install/install_add_dev_existing/install.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add npm:@denotest/[email protected]
Download http://localhost:4260/@denotest/esm-basic
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
Initialize @denotest/[email protected]
3 changes: 3 additions & 0 deletions tests/specs/install/install_add_dev_existing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dependencies": { "@denotest/esm-basic": "^1.0.0" }
}
5 changes: 5 additions & 0 deletions tests/specs/install/install_add_dev_existing/package.json.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"@denotest/esm-basic": "^1.0.0"
}
}

0 comments on commit ccdbeb4

Please sign in to comment.