Skip to content

Commit 9b9b537

Browse files
authored
Merge pull request #42 from jonahwh/master
Support heroku config --json ONLY
2 parents 5e6cbb7 + 792fc1f commit 9b9b537

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ It assumes a standard project layout (see the default value for the globs-option
192192
The easiest/quickest is to run:
193193

194194
```
195-
$ heroku config | bundle exec envied check:heroku
195+
$ heroku config --json | bundle exec envied check:heroku
196196
```
197197

198198
This is equivalent to having the heroku config as your local environment and running `envied check:heroku --groups default production`.

lib/envied/cli.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'thor'
2+
require 'json'
23
require 'envied/env_var_extractor'
34

45
class ENVied
@@ -84,7 +85,7 @@ def check
8485
8586
The Heroku config should be piped to this task:
8687
87-
heroku config | bundle exec envied check:heroku
88+
heroku config --json | bundle exec envied check:heroku
8889
8990
Use the check:heroku:binstub-task to turn this into a bash-script.
9091
@@ -96,16 +97,12 @@ def check
9697
define_method "check:heroku" do
9798
if STDIN.tty?
9899
error <<-ERR
99-
Please pipe the contents of `heroku config` to this task.
100-
I.e. `heroku config | bundle exec envied check:heroku`"
100+
Please pipe the contents of `heroku config --json` to this task.
101+
I.e. `heroku config --json | bundle exec envied check:heroku`"
101102
ERR
102103
exit 1
103104
end
104-
config = STDIN.read
105-
heroku_env = Hash[config.split("\n")[1..-1].each_with_object([]) do |i, res|
106-
res << i.split(":", 2).map(&:strip)
107-
end]
108-
105+
heroku_env = JSON.parse(STDIN.read)
109106
ENV.replace({}).update(heroku_env)
110107

111108
requested_groups = ENV['ENVIED_GROUPS'] || options[:groups]
@@ -119,7 +116,7 @@ def check
119116
long_desc <<-LONG
120117
Generates a shell script to check the Heroku config against the local Envfile.
121118
122-
The same as the check:heroku-task, but all in one script (no need to pipe `heroku config` to it etc.).
119+
The same as the check:heroku-task, but all in one script (no need to pipe `heroku config --json` to it etc.).
123120
124121
LONG
125122
option :dest, banner: "where to put the script", desc: "Default: bin/<app>-env-check or bin/heroku-env-check"

lib/envied/templates/heroku-env-check.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Check the config of a Heroku app against the defined variables in `Envfile`
44

55
<%- if @app %>
6-
HEROKU_APP=<%= @app %> exec heroku config | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
6+
HEROKU_APP=<%= @app %> exec heroku config --json | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
77
<%- else %>
8-
exec heroku config | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
8+
exec heroku config --json | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
99
<%- end %>

0 commit comments

Comments
 (0)