Skip to content

Commit f38ebcf

Browse files
robpreDeviaVir
authored andcommitted
Allow CLI options to direct the archiver to a folder to package as the lambda (#158)
1 parent b891227 commit f38ebcf

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ $ node-lambda deploy --help
136136
-D, --prebuiltDirectory [] Prebuilt directory
137137
-z, --deployZipfile [] Deploy zipfile
138138
-T, --deployTimeout [120000] Deploy Timeout
139+
-G, --sourceDirectory [.] Path to lambda source Directory (e.g. "./some-lambda")
139140
```
140141

141142
## Custom Environment Variables

bin/node-lambda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ var EVENT_FILE = process.env.EVENT_FILE || 'event.json';
7171
var PACKAGE_DIRECTORY = process.env.PACKAGE_DIRECTORY;
7272
var CONTEXT_FILE = process.env.CONTEXT_FILE || 'context.json';
7373
var PREBUILT_DIRECTORY = process.env.PREBUILT_DIRECTORY || '';
74+
var SRC_DIRECTORY = process.env.SRC_DIRECTORY || '';
7475
var DEPLOY_TIMEOUT = process.env.DEPLOY_TIMEOUT || 120000;
7576
var DOCKER_IMAGE = process.env.DOCKER_IMAGE || '';
7677
var DEPLOY_ZIPFILE = process.env.DEPLOY_ZIPFILE || '';
@@ -110,6 +111,7 @@ program
110111
.option('-T, --tracingConfig [' + AWS_TRACING_CONFIG + ']', 'Lambda tracing settings',
111112
AWS_TRACING_CONFIG)
112113
.option('-A, --packageDirectory [' + PACKAGE_DIRECTORY + ']', 'Local Package Directory', PACKAGE_DIRECTORY)
114+
.option('-G, --sourceDirectory [' + SRC_DIRECTORY + ']', 'Path to lambda source Directory (e.g. "./some-lambda")', SRC_DIRECTORY)
113115
.option('-I, --dockerImage [' + DOCKER_IMAGE + ']', 'Docker image for npm install', DOCKER_IMAGE)
114116
.option('-f, --configFile [' + CONFIG_FILE + ']',
115117
'Path to file holding secret environment variables (e.g. "deploy.env")', CONFIG_FILE)

lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ Lambda.prototype._buildAndArchive = function (program, archive_callback) {
512512

513513
var _this = this;
514514
var codeDirectory = _this._codeDirectory(program);
515+
var lambdaSrcDirectory = program.sourceDirectory ? program.sourceDirectory.replace(/\/$/, '') : '.';
515516

516517
_this._cleanDirectory(codeDirectory, function (err) {
517518
if (err) {
@@ -528,7 +529,7 @@ Lambda.prototype._buildAndArchive = function (program, archive_callback) {
528529
copyFunction = '_rsync';
529530
}
530531
// Move files to tmp folder
531-
_this[copyFunction](program, '.', codeDirectory, true, function (err) {
532+
_this[copyFunction](program, lambdaSrcDirectory, codeDirectory, true, function (err) {
532533
if (err) {
533534
return archive_callback(err);
534535
}

0 commit comments

Comments
 (0)