Skip to content

Commit

Permalink
Show a relative path when describing configuration missing
Browse files Browse the repository at this point in the history
For a mounted Rails engine we need the config to be in the application
mount directory e.g. test/dummy/config/webpacker.yml

By running this based on pwd we get this in a Rails engine app:

```
➜  rails-plugin rake app:webpacker:verify_install
RAILS_ENV=development environment is not defined in config/webpacker.yml, falling back to production environment
Configuration test/dummy/config/webpacker.yml file not found.
Make sure webpacker:install is run successfully before running dependent tasks
```

Whereas in a normal Rails installation it outputs unchanged:

```
➜  full-app git:(master) ✗ rake webpacker:verify_install
RAILS_ENV=development environment is not defined in config/webpacker.yml, falling back to production environment
Configuration config/webpacker.yml file not found.
Make sure webpacker:install is run successfully before running dependent tasks
```
  • Loading branch information
kevindew committed Oct 3, 2018
1 parent 4b0ed13 commit 8580f9a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/tasks/webpacker/verify_install.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace :webpacker do
desc "Verifies if Webpacker is installed"
task verify_install: [:check_node, :check_yarn, :check_binstubs] do
unless Webpacker.config.config_path.exist?
$stderr.puts "Configuration config/webpacker.yml file not found. \n"\
path = Webpacker.config.config_path.relative_path_from(Pathname.new(pwd)).to_s
$stderr.puts "Configuration #{path} file not found. \n"\
"Make sure webpacker:install is run successfully before " \
"running dependent tasks"
exit!
Expand Down

0 comments on commit 8580f9a

Please sign in to comment.