8000 Post install script by navihtot · Pull Request #68 · motdotla/node-lambda · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@navihtot
Copy link
Contributor
@navihtot navihtot commented Apr 5, 2016

If file post_install.sh exists than it is run after npm install --production and before creating .zip and deploying to AWS Lambda

Fixes #67

@DeviaVir
Copy link
Collaborator
DeviaVir commented Apr 8, 2016

Hi @navihtot!

Thanks for your contribution! Could you explain the usecase and add a bit of documentation on how others might use this function?

@navihtot
Copy link
Contributor Author

Hi, my usecase is that I needed to use CamanJS library on Lambda (which is dependent on node-canvas and fibers). The problem is that canvas needs native libraries compiled on same version of Amazon Linux that lambda runs on, and modules needed to be compiled with node-gyp after that.
So I needed a way that after npm install I can pull my precompiled libs and modules and overwrite existing ones in node_modules folder.

But I presume someone could have a need to do any other action with .sh script after npm install and before deployment.
Usage is simple, if script with that name exists its runs else its skipped.

I'll try to add some simple documentation later today.

Btw - lambda now finally supports newer node version 4.3.2., and I tried to deploy with AWS_RUNTIME=nodejs4.3 in .env - it works!

@navihtot
Copy link
Contributor Author

There is also a npm -> https://www.npmjs.com/package/node-lambda-postinstall

@navihtot
Copy link
Contributor Author

Here, added section Post install script with short description in readme.md

README.md Outdated

## Post install script

When running `node-lambda deploy` if you need to do some action after `npm install --production` and before deploying to AWS Lambda (i.e. replace some modules with precompiled ones or download some libraries) you can create `post_install.sh` script. If the file exists the script will be runned (and output shown after execution) if not it is skipped. Make sure that the script is executable.
Copy link
Collaborator

Choose a reason for hiding this comment

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

the script will be runned => the script will be executed

@DeviaVir
Copy link
Collaborator

Could you rebase this branch against current master so it's good to merge? I'm onboard with the changes 👍

@navihtot
Copy link
Contributor Author

not sure how to do this. i get many conflicts... i could create another fork/branch from current master and implement it there. but wont have time for that until the end of the week.

@DeviaVir
Copy link
Collaborator

@navihtot after you've merged in https://github.com/navihtot/node-lambda/pull/1 into your branch, you can rebase by doing the following on your machine:

git remote add upstream git@github.com:motdotla/node-lambda.git
git fetch upstream
git checkout post-install-script
git rebase -i upstream/master

from there you'll see a vi editor where you can pick specific commits, replace all "pick"'s by "squash" except the first one. After that is completed and you have set the commit message, you can run git push --force and your commits will be squashed ending up in a much nicer commit history in this repo.

@navihtot
Copy link
Contributor Author

tried it. i still get too much conflicts when i do rebase :( should I just create fork again an add functionality from scratch ?

after all it just a one function added...

@DeviaVir
Copy link
Collaborator

@navihtot that's probably the fastest way if you don't want to deal with the merge conflicts now. If you set that up and create the PR I'll get it merged ASAP so you don't have to deal with any conflicts later on.

@navihtot
Copy link
Contributor Author

here I created another pull request #78

@DeviaVir DeviaVir closed this Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0