Skip to content
This repository was archived by the owner on May 15, 2020. It is now read-only.
Open
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
20 changes: 12 additions & 8 deletions lib/rack_application.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions src/rack_application.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async = require "async"
fs = require "fs"
nack = require "nack"

{bufferLines, pause, sourceScriptEnv} = require "./util"
{bufferLines, pause, sourceScriptEnv, quote} = require "./util"
{join, basename, resolve} = require "path"

module.exports = class RackApplication
Expand Down Expand Up @@ -88,15 +88,24 @@ module.exports = class RackApplication

@statCallbacks.push callback

# Collect environment variables from `.powrc` and `.powenv`, in that
# order, if present. The idea is that `.powrc` files can be checked
# into a source code repository for global configuration, leaving
# `.powenv` free for any necessary local overrides.
# Collect environment variables from `~/.powrc`, `.powrc` and `.powenv`,
# in that order, if present. The idea is that `.powrc` files can be checked
# into a source code repository for global configuration, leaving `.powenv`
# free for any necessary local overrides. The files will be executed from
# the project root.
loadScriptEnvironment: (env, callback) ->
async.reduce [".powrc", ".envrc", ".powenv"], env, (env, filename, callback) =>
fs.exists script = join(@root, filename), (scriptExists) ->
home = process.env["HOME"]
envFiles = [
join(home, ".powrc"),
join(@root, ".powrc"),
join(@root, ".envrc"),
join(@root, ".powenv"),
]
before = "cd #{quote @root}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would do this root path quoting change in a separate PR 😁

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean here, I can totally update the PR and cd #{@root} if you want.

I quoted because I was it's used all over the place in sourceScriptEnv, the alternative I see is to allow setting cwd as an option.

async.reduce envFiles, env, (env, script, callback) =>
fs.exists script, (scriptExists) ->
if scriptExists
sourceScriptEnv script, env, callback
sourceScriptEnv script, env, {before}, callback
else
callback null, env
, callback
Expand Down
1 change: 1 addition & 0 deletions src/util.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ exec = (command, options, callback) ->

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

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