diff --git a/haxetool/haxe.js b/haxetool/haxe.js index ed5ae3b..58fd4cf 100755 --- a/haxetool/haxe.js +++ b/haxetool/haxe.js @@ -56,7 +56,9 @@ class Haxe extends Sdk { } prepare() { - return Promise.all([this.neko.prepare(), super.prepare()]); + return Promise.all([this.neko.prepare(), super.prepare()]).then(() => { + fs.copyFileSync(path.resolve(__dirname, '..', 'template/activate'), path.resolve(this.path, 'activate')); + }); } get link() { diff --git a/package.json b/package.json index 54f5d42..96da599 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-haxetool", - "version": "0.0.13", + "version": "0.0.14", "description": "HaXe Tool for Gulp", "main": "index.js", "dependencies": { diff --git a/template/activate b/template/activate new file mode 100644 index 0000000..ff56a38 --- /dev/null +++ b/template/activate @@ -0,0 +1,69 @@ +# From python venv activate + +deactivate () { + # reset old environment variables + # ! [ -z ${VAR+_} ] returns true if VAR is declared at all + if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then + PATH="$_OLD_VIRTUAL_PATH" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if ! [ -z "${_OLD_VIRTUAL_LD_LIBRARY_PATH+_}" ] ; then + LD_LIBRARY_PATH="$_OLD_VIRTUAL_LD_LIBRARY_PATH" + export LD_LIBRARY_PATH + unset _OLD_VIRTUAL_LD_LIBRARY_PATH + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then + hash -r 2>/dev/null + fi + + if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then + PS1="$_OLD_VIRTUAL_PS1" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset HAXE_HOME + if [ ! "${1-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +HAXE_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +export HAXE_HOME + +HAXE_STD_PATH="${HAXE_HOME}/std" +export HAXE_STD_PATH + +_OLD_VIRTUAL_PATH="$PATH" +PATH="${PATH}:${HAXE_HOME}" +export PATH + +_OLD_VIRTUAL_LD_LIBRARY_PATH="$PATH" +LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HAXE_HOME}" +export LD_LIBRARY_PATH + +if [ -z "${HAXE_DISABLE_PROMPT-}" ] ; then + _OLD_VIRTUAL_PS1="$PS1" + if [ "x" != x ] ; then + PS1="$PS1" + else + PS1="(haxe) $PS1" + fi + export PS1 +fi + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then + hash -r 2>/dev/null +fi