Skip to content

Commit 42cac04

Browse files
abetomoDeviaVir
authored andcommitted
How about it if you have the option to specify the zip file? (#199)
* Implemented to pass created zip file when deploying * Added to README about '--deployZipfile' option
1 parent e34799e commit 42cac04

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ $ node-lambda deploy --help
129129
-A, --packageDirectory [] Local package directory
130130
-x, --excludeGlobs [] Add a space separated list of file(type)s to ignore (e.g. "*.json .env")
131131
-D, --prebuiltDirectory [] Prebuilt directory
132+
-z, --deployZipfile [] Deploy zipfile
132133
```
133134

134135
## Custom Environment Variables

bin/node-lambda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var EVENT_FILE = process.env.EVENT_FILE || 'event.json';
3535
var PACKAGE_DIRECTORY = process.env.PACKAGE_DIRECTORY;
3636
var CONTEXT_FILE = process.env.CONTEXT_FILE || 'context.json';
3737
var PREBUILT_DIRECTORY = process.env.PREBUILT_DIRECTORY || '';
38+
var DEPLOY_ZIPFILE = process.env.DEPLOY_ZIPFILE || '';
3839

3940
program
4041
.command('deploy')
@@ -67,6 +68,7 @@ program
6768
.option('-x, --excludeGlobs [' + EXCLUDE_GLOBS + ']',
6869
'Space-separated glob pattern(s) for additional exclude files (e.g. "event.json dotenv.sample")', EXCLUDE_GLOBS)
6970
.option('-D, --prebuiltDirectory [' + PREBUILT_DIRECTORY + ']', 'Prebuilt directory', PREBUILT_DIRECTORY)
71+
.option('-z, --deployZipfile [' + DEPLOY_ZIPFILE + ']', 'Deploy zipfile', DEPLOY_ZIPFILE)
7072
.action(function (prg) {
7173
lambda.deploy(prg);
7274
});

lib/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,18 @@ Lambda.prototype._uploadNew = function (lambda, params, cb) {
341341
});
342342
};
343343

344+
Lambda.prototype._readArchive = function (program, archive_callback) {
345+
if (!fs.existsSync(program.deployZipfile)) {
346+
var err = new Error('No such Zipfile [' + program.deployZipfile + ']');
347+
return archive_callback(err);
348+
}
349+
fs.readFile(program.deployZipfile, archive_callback);
350+
},
351+
344352
Lambda.prototype._archive = function (program, archive_callback) {
353+
if (program.deployZipfile && fs.existsSync(program.deployZipfile)) {
354+
return this._readArchive(program, archive_callback);
355+
}
345356
return program.prebuiltDirectory ?
346357
this._archivePrebuilt(program, archive_callback) :
347358
this._buildAndArchive(program, archive_callback);

0 commit comments

Comments
 (0)