Skip to content

Commit

Permalink
How about it if you have the option to specify the zip file? (#199)
Browse files Browse the repository at this point in the history
* Implemented to pass created zip file when deploying

* Added to README about '--deployZipfile' option
  • Loading branch information
abetomo authored and DeviaVir committed Mar 27, 2017
1 parent e34799e commit 42cac04
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ $ node-lambda deploy --help
-A, --packageDirectory [] Local package directory
-x, --excludeGlobs [] Add a space separated list of file(type)s to ignore (e.g. "*.json .env")
-D, --prebuiltDirectory [] Prebuilt directory
-z, --deployZipfile [] Deploy zipfile
```

## Custom Environment Variables
Expand Down
2 changes: 2 additions & 0 deletions bin/node-lambda
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var EVENT_FILE = process.env.EVENT_FILE || 'event.json';
var PACKAGE_DIRECTORY = process.env.PACKAGE_DIRECTORY;
var CONTEXT_FILE = process.env.CONTEXT_FILE || 'context.json';
var PREBUILT_DIRECTORY = process.env.PREBUILT_DIRECTORY || '';
var DEPLOY_ZIPFILE = process.env.DEPLOY_ZIPFILE || '';

program
.command('deploy')
Expand Down Expand Up @@ -67,6 +68,7 @@ program
.option('-x, --excludeGlobs [' + EXCLUDE_GLOBS + ']',
'Space-separated glob pattern(s) for additional exclude files (e.g. "event.json dotenv.sample")', EXCLUDE_GLOBS)
.option('-D, --prebuiltDirectory [' + PREBUILT_DIRECTORY + ']', 'Prebuilt directory', PREBUILT_DIRECTORY)
.option('-z, --deployZipfile [' + DEPLOY_ZIPFILE + ']', 'Deploy zipfile', DEPLOY_ZIPFILE)
.action(function (prg) {
lambda.deploy(prg);
});
Expand Down
11 changes: 11 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,18 @@ Lambda.prototype._uploadNew = function (lambda, params, cb) {
});
};

Lambda.prototype._readArchive = function (program, archive_callback) {
if (!fs.existsSync(program.deployZipfile)) {
var err = new Error('No such Zipfile [' + program.deployZipfile + ']');
return archive_callback(err);
}
fs.readFile(program.deployZipfile, archive_callback);
},

Lambda.prototype._archive = function (program, archive_callback) {
if (program.deployZipfile && fs.existsSync(program.deployZipfile)) {
return this._readArchive(program, archive_callback);
}
return program.prebuiltDirectory ?
this._archivePrebuilt(program, archive_callback) :
this._buildAndArchive(program, archive_callback);
Expand Down

0 comments on commit 42cac04

Please sign in to comment.