Skip to content
This repository was archived by the owner on May 15, 2020. It is now read-only.

Commit e11ffea

Browse files
committed
Load ~/.powrc and ~/.powenv too
1 parent 3d1fa86 commit e11ffea

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

lib/rack_application.js

Lines changed: 12 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rack_application.coffee

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async = require "async"
2828
fs = require "fs"
2929
nack = require "nack"
3030

31-
{bufferLines, pause, sourceScriptEnv} = require "./util"
31+
{bufferLines, pause, sourceScriptEnv, quote} = require "./util"
3232
{join, basename, resolve} = require "path"
3333

3434
module.exports = class RackApplication
@@ -89,14 +89,24 @@ module.exports = class RackApplication
8989
@statCallbacks.push callback
9090

9191
# Collect environment variables from `.powrc` and `.powenv`, in that
92-
# order, if present. The idea is that `.powrc` files can be checked
93-
# into a source code repository for global configuration, leaving
94-
# `.powenv` free for any necessary local overrides.
92+
# order, if present from both $HOME and the project root. The idea is
93+
# that `.powrc` files can be checked into a source code repository for
94+
# global configuration, leaving `.powenv` free for any necessary local
95+
# overrides. The files will be executed from the project root.
9596
loadScriptEnvironment: (env, callback) ->
96-
async.reduce [".powrc", ".envrc", ".powenv"], env, (env, filename, callback) =>
97-
fs.exists script = join(@root, filename), (scriptExists) ->
97+
home = process.env['HOME']
98+
envFiles = [
99+
join(home, ".powrc"),
100+
join(home, ".powenv"),
101+
join(@root, ".powrc"),
102+
join(@root, ".envrc"),
103+
join(@root, ".powenv"),
104+
]
105+
before = "cd #{quote @root}"
106+
async.reduce envFiles, env, (env, script, callback) =>
107+
fs.exists script, (scriptExists) ->
98108
if scriptExists
99-
sourceScriptEnv script, env, callback
109+
sourceScriptEnv script, env, {before}, callback
100110
else
101111
callback null, env
102112
, callback

src/util.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ exec = (command, options, callback) ->
170170

171171
# Single-quote a string for command line execution.
172172
quote = (string) -> "'" + string.replace(/\'/g, "'\\''") + "'"
173+
exports.quote = quote
173174

174175
# Generate and return a unique temporary filename based on the
175176
# current process's PID, the number of milliseconds elapsed since the

0 commit comments

Comments
 (0)