Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about it if you have the option to specify the zip file? #199

Merged
merged 2 commits into from
Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -34,6 +34,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 @@ -64,6 +65,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 @@ -344,7 +344,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