Skip to content

Commit e738dfe

Browse files
committed
fix: ensure that pnpm install behaviour is consistent with other package managers, even in CI
1 parent d737e2e commit e738dfe

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

lib/package_json/managers/pnpm_like.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,15 @@ def with_native_args(
108108
)
109109
args = [*extra_args]
110110

111-
args << "--frozen-lockfile" if frozen
111+
# we make frozen lockfile behaviour consistent with the other package managers
112+
# as pnpm automatically enables frozen lockfile if it detects it's running in CI
113+
unless frozen.nil?
114+
flag = "--no-frozen-lockfile"
115+
flag = "--frozen-lockfile" if frozen
116+
117+
args << flag
118+
end
119+
112120
args << "--ignore-scripts" if ignore_scripts
113121
args << "--no-optional" if omit_optional_deps
114122

spec/package_json/managers/pnpm_like_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
with_package_json_file do
2323
manager.install
2424

25-
expect_manager_to_be_invoked_with("install")
25+
expect_manager_to_be_invoked_with("install --no-frozen-lockfile")
2626
end
2727
end
2828

@@ -42,23 +42,23 @@
4242
with_package_json_file do
4343
manager.install(ignore_scripts: true)
4444

45-
expect_manager_to_be_invoked_with("install --ignore-scripts")
45+
expect_manager_to_be_invoked_with("install --no-frozen-lockfile --ignore-scripts")
4646
end
4747
end
4848

4949
it "supports legacy_peer_deps" do
5050
with_package_json_file do
5151
manager.install(legacy_peer_deps: true)
5252

53-
expect_manager_to_be_invoked_with("install")
53+
expect_manager_to_be_invoked_with("install --no-frozen-lockfile")
5454
end
5555
end
5656

5757
it "supports omit_optional_deps" do
5858
with_package_json_file do
5959
manager.install(omit_optional_deps: true)
6060

61-
expect_manager_to_be_invoked_with("install --no-optional")
61+
expect_manager_to_be_invoked_with("install --no-frozen-lockfile --no-optional")
6262
end
6363
end
6464

@@ -82,7 +82,7 @@
8282

8383
describe "#native_install_command" do
8484
it "returns the full command" do
85-
expect(manager.native_install_command).to eq("#{package_manager_cmd} install")
85+
expect(manager.native_install_command).to eq("#{package_manager_cmd} install --no-frozen-lockfile")
8686
end
8787

8888
context "when passing the usual options" do
@@ -94,19 +94,19 @@
9494

9595
it "supports ignore_scripts" do
9696
expect(manager.native_install_command(ignore_scripts: true)).to eq(
97-
"#{package_manager_cmd} install --ignore-scripts"
97+
"#{package_manager_cmd} install --no-frozen-lockfile --ignore-scripts"
9898
)
9999
end
100100

101101
it "supports legacy_peer_deps" do
102102
expect(manager.native_install_command(legacy_peer_deps: true)).to eq(
103-
"#{package_manager_cmd} install"
103+
"#{package_manager_cmd} install --no-frozen-lockfile"
104104
)
105105
end
106106

107107
it "supports omit_optional_deps" do
108108
expect(manager.native_install_command(omit_optional_deps: true)).to eq(
109-
"#{package_manager_cmd} install --no-optional"
109+
"#{package_manager_cmd} install --no-frozen-lockfile --no-optional"
110110
)
111111
end
112112

0 commit comments

Comments
 (0)