mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
fix(install): update lockfile when using package.json (#26458)
This commit makes sure that `deno add`, `deno install` and `deno remove` update the lockfile if only `package.json` file is present. Fixes https://github.com/denoland/deno/issues/26270
This commit is contained in:
parent
7b912da996
commit
dca94aba82
7 changed files with 55 additions and 0 deletions
|
@ -723,6 +723,10 @@ async fn npm_install_after_modification(
|
|||
// npm install
|
||||
cache_deps::cache_top_level_deps(&cli_factory, jsr_resolver).await?;
|
||||
|
||||
if let Some(lockfile) = cli_factory.cli_options()?.maybe_lockfile() {
|
||||
lockfile.write_if_changed()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"tests": {
|
||||
"updates_lockfile": {
|
||||
"steps": [
|
||||
{
|
||||
"args": "add npm:@denotest/esm-basic npm:@denotest/say-hello",
|
||||
"output": "add.out"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"eval",
|
||||
"console.log(Deno.readTextFileSync('deno.lock'))"
|
||||
],
|
||||
"output": "lockfile_add.out"
|
||||
},
|
||||
{
|
||||
"args": "remove @denotest/esm-basic @denotest/say-hello",
|
||||
"output": "remove.out"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"eval",
|
||||
"console.log(Deno.readTextFileSync('deno.lock'))"
|
||||
],
|
||||
"output": "lockfile_remove.out"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
5
tests/specs/add/update_lockfile_if_package_json/add.out
Normal file
5
tests/specs/add/update_lockfile_if_package_json/add.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
[UNORDERED_START]
|
||||
Add npm:@denotest/esm-basic@1.0.0
|
||||
Add npm:@denotest/say-hello@1.0.0
|
||||
[UNORDERED_END]
|
||||
[WILDCARD]
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"npm:@denotest/esm-basic@1": "1.0.0",
|
||||
"npm:@denotest/say-hello@1": "1.0.0"
|
||||
},
|
||||
[WILDCARD]
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": "4"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[UNORDERED_START]
|
||||
Removed @denotest/esm-basic
|
||||
Removed @denotest/say-hello
|
||||
[UNORDERED_END]
|
Loading…
Reference in a new issue