Skip to content

Commit 30ffa7c

Browse files
jcoynedhh
andauthored
Add support for npm 9+ (#139)
* Add support for npm 9+ Fixes #138 * Simplify case * Simplify case * Simplify case Co-authored-by: David Heinemeier Hansson <david@basecamp.com>
1 parent 98e8165 commit 30ffa7c

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

lib/install/esbuild/install.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
say "Add build script"
55
build_script = "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets"
66

7-
if (`npx -v`.to_f < 7.1 rescue "Missing")
8-
say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
9-
else
7+
case `npx -v`.to_f
8+
when 7.1...8.0
109
run %(npm set-script build "#{build_script}")
1110
run %(yarn build)
11+
when 8.0..
12+
run %(npm pkg set scripts.build="#{build_script}")
13+
run %(yarn build)
14+
else
15+
say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
1216
end

lib/install/rollup/install.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
say "Add build script"
66
build_script = "rollup -c --bundleConfigAsCjs rollup.config.js"
77

8-
if (`npx -v`.to_f < 7.1 rescue "Missing")
9-
say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
10-
else
8+
case `npx -v`.to_f
9+
when 7.1...8.0
1110
run %(npm set-script build "#{build_script}")
1211
run %(yarn build)
12+
when 8.0..
13+
run %(npm pkg set scripts.build="#{build_script}")
14+
run %(yarn build)
15+
else
16+
say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
1317
end

lib/install/webpack/install.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
say "Add build script"
66
build_script = "webpack --config webpack.config.js"
77

8-
if (`npx -v`.to_f < 7.1 rescue "Missing")
9-
say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
10-
else
8+
case `npx -v`.to_f
9+
when 7.1...8.0
1110
run %(npm set-script build "#{build_script}")
1211
run %(yarn build)
12+
when 8.0..
13+
run %(npm pkg set scripts.build="#{build_script}")
14+
run %(yarn build)
15+
else
16+
say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
1317
end

0 commit comments

Comments
 (0)