Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to keep local dependencies #11

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Add as a first buildpack in the chain. Set `PROJECT_PATH` environment variable t
2. `heroku buildpacks:set https://github.com/timanovsky/subdir-heroku-buildpack`
3. `heroku buildpacks:add heroku/nodejs` or whatever buildpack you need for your application
4. `heroku config:set PROJECT_PATH=projects/nodejs/frontend` pointing to what you want to be a project root.
5. `heroku config:set KEEPS=./dependencies:./vendor` to specify what you want to keep using GLOBIGNORE syntax.
5. `heroku config:set UNLINK=projects/nodejs/frontend/dependencies` to unlink a symlink that may be used.
5. Deploy your project to Heroku.

# How it works
Expand Down
29 changes: 25 additions & 4 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,37 @@ if [ -f $ENV_DIR/PROJECT_PATH ]; then
PROJECT_PATH=`cat $ENV_DIR/PROJECT_PATH`
if [ -d $BUILD_DIR/$PROJECT_PATH ]; then
echo "-----> Subdir buildpack in $PROJECT_PATH"

# Optionally, unlink a folder. This may be needed to keep Gemfiles, etc. unchanged.
UNLINK=''
if [ -f $ENV_DIR/UNLINK ]; then
UNLINK=`cat $ENV_DIR/UNLINK`
echo " unlinking $BUILD_DIR/$UNLINK"
unlink $BUILD_DIR/$UNLINK
fi

echo " creating cache: $CACHE_DIR"
mkdir -p $CACHE_DIR
TMP_DIR=`mktemp -d $CACHE_DIR/subdirXXXXX`
echo " created tmp dir: $TMP_DIR"
echo " moving working dir: $PROJECT_PATH to $TMP_DIR"
cp -R $BUILD_DIR/$PROJECT_PATH/. $TMP_DIR/
echo " cleaning build dir $BUILD_DIR"
rm -rf $BUILD_DIR/*

echo " cleaning build dir $BUILD_DIR"

# Optionally, keep some files using GLOBIGNORE pattern
KEEPS=''
if [ -f $ENV_DIR/KEEPS ]; then
KEEPS=`cat $ENV_DIR/KEEPS`
echo " ignoring $KEEPS"
fi

# Enter build dir
cd $BUILD_DIR
(GLOBIGNORE=".:..:.buildpacks:$KEEPS"; rm -rf ./*)
cd -
# End entering build dir

echo " copying preserved work dir from cache $TMP_DIR to build dir $BUILD_DIR"
cp -R $TMP_DIR/. $BUILD_DIR/
echo " cleaning tmp dir $TMP_DIR"
Expand All @@ -30,5 +53,3 @@ fi

echo "PROJECT_PATH is undefined"
exit 1