Skip to content

Commit

Permalink
feat: allow skipping yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Nov 8, 2023
1 parent 371f8a8 commit 06c871b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion template/Dockerfile.tt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
<% if yarn_version == 'latest' %>

RUN npm install -g yarn
<% else %>
<% elsif yarn_version %>

ARG YARN_VERSION
RUN npm install -g yarn@$YARN_VERSION
Expand Down
3 changes: 2 additions & 1 deletion template/_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
unless selected_node_version =~ /^\s*no?\s*$/
node_version = selected_node_version.empty? ? DEFAULT_NODE_VERSION : selected_node_version

yarn_version = ask("Which Yarn version do you want to install? (Press ENTER to install the latest one)") || ""
yarn_version = ask("Which Yarn version do you want to install? (Press ENTER to install the latest one, type 'n/no' to skip installing Yarn)") || ""
yarn_version = "latest" if yarn_version.empty?
yarn_version = false if yarn_version =~ /^\s*no?\s*$/
end
end
21 changes: 19 additions & 2 deletions test/template/node_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_default_node_versions

assert_line_printed(
output,
"Which Yarn version do you want to install? (Press ENTER to install the latest one)"
"Which Yarn version do you want to install? (Press ENTER to install the latest one, type 'n/no' to skip installing Yarn)"
)

assert_line_printed(
Expand All @@ -43,7 +43,7 @@ def test_custom_node_versions

assert_line_printed(
output,
"Which Yarn version do you want to install? (Press ENTER to install the latest one)"
"Which Yarn version do you want to install? (Press ENTER to install the latest one, type 'n/no' to skip installing Yarn)"
)

assert_line_printed(
Expand All @@ -70,4 +70,21 @@ def test_skip_node
)
end
end

def test_skip_yarn
run_generator(input: ["\r", "n"]) do |output|
assert_line_printed(
output,
"Which Node version do you want to install? (Press ENTER to use 18, type 'n/no' to skip installing Node)"
)
assert_line_printed(
output,
"NODE_VERSION=18"
)
assert_line_printed(
output,
"YARN_VERSION=false"
)
end
end
end

0 comments on commit 06c871b

Please sign in to comment.