Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ main
ember:heroku`. Rails serves the twelve-factor behaviour the gem backported
natively since `5.0`, and every Rails version this gem supports is `>= 5.2`.
To upgrade, remove `rails_12factor` from your project's `Gemfile`
* Replace `EmberCli::App#yarn_enabled?` with `EmberCli::App#yarn?`

0.13.2
------
Expand Down
4 changes: 2 additions & 2 deletions lib/ember_cli/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def mountable?
deploy.mountable?
end

def yarn_enabled?
options.fetch(:yarn, false)
def yarn?
paths.yarn?
end

def bower?
Expand Down
8 changes: 4 additions & 4 deletions lib/ember_cli/path_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def node_modules
@node_modules ||= root.join("node_modules")
end

def yarn?
app_options[:yarn].present? || app_options[:yarn_path].present?
end

def tee
@tee ||= path_for_executable("tee")
end
Expand Down Expand Up @@ -169,10 +173,6 @@ def package_manager
end
end

def yarn?
app_options[:yarn] || app_options[:yarn_path]
end

def app_name
app.name
end
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/ember/heroku/heroku_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def copy_package_json_file
end

def identify_as_yarn_project
if EmberCli.any?(&:yarn_enabled?)
if EmberCli.any?(&:yarn?)
template "yarn.lock.erb", "yarn.lock"
end
end
Expand Down
24 changes: 18 additions & 6 deletions spec/lib/ember_cli/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,36 @@
end
end

describe "yarn_enabled?" do
describe "#yarn?" do
context "when configured with yarn: true" do
it "returns true" do
app = EmberCli::App.new("with-yarn", yarn: true)

yarn_enabled = app.yarn_enabled?

expect(yarn_enabled).to be true
expect(app.yarn?).to be true
end
end

context "when configured with yarn: false" do
it "returns false" do
app = EmberCli::App.new("without-yarn", yarn: false)

yarn_enabled = app.yarn_enabled?
expect(app.yarn?).to be false
end
end

context "when configured with yarn_path alone" do
it "returns true, matching the executable the installer runs" do
app = EmberCli::App.new("with-yarn-path", yarn_path: "/usr/bin/yarn")

expect(app.yarn?).to be true
end
end

context "when configured with neither" do
it "returns false" do
app = EmberCli::App.new("without-yarn")

expect(yarn_enabled).to be false
expect(app.yarn?).to be false
end
end
end
Expand Down
22 changes: 22 additions & 0 deletions spec/lib/ember_cli/path_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,28 @@
end
end

describe "#yarn?" do
it "is true when yarn is requested" do
app = build_app(options: { yarn: true })
path_set = build_path_set(app: app)

expect(path_set).to be_yarn
end

it "is true when only the yarn executable is named" do
app = build_app(options: { yarn_path: "/usr/bin/yarn" })
path_set = build_path_set(app: app)

expect(path_set).to be_yarn
end

it "is false when yarn is neither requested nor named" do
path_set = build_path_set

expect(path_set).not_to be_yarn
end
end

describe "#yarn" do
it "can be overridden" do
fake_yarn = create_executable(ember_cli_root.join("yarn"))
Expand Down