Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Add REBAR to environment before executing hooks #229

Merged
merged 1 commit into from
Jun 14, 2014

Conversation

tolbrino
Copy link
Contributor

REBAR will be set to the rebar binary which was executed and runs the
builds. Enables the use of the same binary for rebar invocations as
part of a pre or post hook like so:

${REBAR} escriptize

Path = escript:script_name(),
[{"REBAR", Path} | Env0]
catch
_:_ -> % rebar was involed programmatically
Copy link

Choose a reason for hiding this comment

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

s/involed/invoked/

@uwiger
Copy link
Contributor

uwiger commented Feb 24, 2014

Note, it really needs to be filename:absname(escript:script_name()) in order to have a working path once rebar moves down into dependent apps.

BTW, this is already stored in xconf here:
https://github.com/rebar/rebar/blob/master/src/rebar.erl#L156

@ghost
Copy link

ghost commented Feb 24, 2014

@uwiger good catch, that can and should be reused.

[];
patch_env([{env, Env0} | Rest]) ->
Env = try
Path = escript:script_name(),
Copy link

Choose a reason for hiding this comment

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

As @uwiger suggested, we should reuse the existing xconf variable here:

Path = rebar_config:get_xconf(Config, escript, ""),

@tolbrino
Copy link
Contributor Author

Thanks guys, I've updated the PR.

@@ -314,6 +315,21 @@ processing_base_dir(Config) ->
processing_base_dir(Config, Dir) ->
Dir =:= rebar_config:get_xconf(Config, base_dir).

%% @doc Returns list of environment variables including 'REBAR' which points to the rebar executable used to execute the currently running command. The environment is not modified if rebar was invoked programmatically.
Copy link

Choose a reason for hiding this comment

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

Overlong line.

@Vagabond
Copy link
Contributor

Vagabond commented Mar 5, 2014

This looks fine, just needs a rebase.

@ghost
Copy link

ghost commented May 29, 2014

What's the status?

REBAR will be set to the rebar binary which was executed and runs the
builds. Enables the use of the same binary for rebar invocations as
part of a pre or post hook like so:

    ${REBAR} escriptize
@tolbrino
Copy link
Contributor Author

tolbrino commented Jun 2, 2014

I've rebased the patch. It's been in use without issues.

tsloughter added a commit that referenced this pull request Jun 14, 2014
Add REBAR to environment before executing hooks
@tsloughter tsloughter merged commit 9380583 into rebar:master Jun 14, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants