Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Created January 4, 2019 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardBronosky/f5b67308b82ee8ea95ee2ec9b8e0d167 to your computer and use it in GitHub Desktop.
Save RichardBronosky/f5b67308b82ee8ea95ee2ec9b8e0d167 to your computer and use it in GitHub Desktop.
#!/bin/bash
# WHY?
# Because lambda function project directories tend to have unnecessary files (like tests, docs, etc.)
# This skips the cruft and zip up only these files:
# ./node_modules (This is recursive.)
# ./*.js (This is not recursive. All *.js files in the base directory are included, subdirectories are excluded.)
# ./*.json (This is not recursive. All *.json files in the base directory are included, subdirectories are excluded.)
# Note:
# Put your tests in ./tests/tests.js rather than ./tests.js to keep them from getting build into the zip
find -E . -iregex '^\./[^/]*\.js(on)?' -or -path './node_modules/*' | zip -@ lambda.zip
{
"name": "example-package",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "find -E . -iregex '^\\./[^/]*\\.js(on)?' -or -path './node_modules/*' | zip -@ lambda.zip",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.382.0"
},
"devDependencies": {
"mocha": "^5.2.0",
"standard": "^12.0.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment