diff --git a/template/Dockerfile.tt b/template/Dockerfile.tt index c942165..feae34c 100644 --- a/template/Dockerfile.tt +++ b/template/Dockerfile.tt @@ -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 diff --git a/template/_node.rb b/template/_node.rb index cbb4610..6026b8f 100644 --- a/template/_node.rb +++ b/template/_node.rb @@ -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 diff --git a/test/template/node_test.rb b/test/template/node_test.rb index 59c1fd2..7c9cc46 100644 --- a/test/template/node_test.rb +++ b/test/template/node_test.rb @@ -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( @@ -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( @@ -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