File tree Expand file tree Collapse file tree 2 files changed +37
-6
lines changed Expand file tree Collapse file tree 2 files changed +37
-6
lines changed Original file line number Diff line number Diff line change 1
- # Dotenv:: Heroku
1
+ # Dotenv Heroku
2
2
3
- TODO: Write a gem description
3
+ Support for config push and pull via Rake tasks for
4
+ [ dotenv] ( https://github.com/bkeepers/dotenv ) . The rake tasks rely on the
5
+ ` heroku ` excutable to be present in the PATH.
4
6
5
7
## Installation
6
8
@@ -18,7 +20,30 @@ Or install it yourself as:
18
20
19
21
## Usage
20
22
21
- TODO: Write usage instructions here
23
+ Add
24
+
25
+ require "dotenv-heroku/tasks"
26
+
27
+ to your Rakefile.
28
+
29
+ You can now run
30
+
31
+ $ rake config:pull
32
+
33
+ to pull the current heroku config to the local .env file, you can also pass the
34
+ desired file as an argument
35
+
36
+ $ rake config:pull\[my_current_config\]
37
+
38
+ You can also push the config to heroku via
39
+
40
+ $ rake config:push
41
+
42
+ to push the config from the .env file, or
43
+
44
+ $ rake config:push\[my_current_config\]
45
+
46
+ to push the config from the my_current_config file
22
47
23
48
## Contributing
24
49
Original file line number Diff line number Diff line change 1
1
require "mkmf"
2
+ # Make the MakeMakefile logger write file output to null.
3
+ module MakeMakefile ::Logging
4
+ @logfile = File ::NULL
5
+ end
2
6
3
7
namespace :config do
4
8
task :executable do
5
9
fail "missing heroku executable from the PATH" unless find_executable "heroku"
6
10
end
7
11
8
12
desc "push the .env file to heroku config"
9
- task :push , :env_file , :needs => :executable do |t , args |
13
+ task :push , [ :env_file ] => :executable do |t , args |
10
14
args . with_defaults ( env_file : ".env" )
11
15
12
16
File . readlines ( args [ :env_file ] ) . map ( &:strip ) . each do |value |
15
19
end
16
20
17
21
desc "pull the config from heroku and write to .env file"
18
- task :pull , :env_file , :needs => :executable do |t , args |
22
+ task :pull , [ :env_file ] => :executable do |t , args |
19
23
args . with_defaults ( env_file : ".env" )
20
24
21
- remote_config = sh ( "heroku config" ) . split ( "/n" )
25
+ remote_config = `heroku config`
26
+ remote_config or fail "could not fetch remote config"
27
+ remote_config = remote_config . split ( "\n " )
22
28
remote_config . shift # remove the header
23
29
24
30
# reformat the lines from
You can’t perform that action at this time.
0 commit comments