Skip to content

Commit

Permalink
Replace with arrow function (#342)
Browse files Browse the repository at this point in the history
* Replace with arrow function in index.js

* Replace with arrow function in bin/node-lambda

* Replace with arrow function in test/main.js

* Replace with arrow function in lib/main.js
  • Loading branch information
abetomo authored and DeviaVir committed Jul 4, 2017
1 parent 0d144c8 commit 0ad8016
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 83 deletions.
18 changes: 5 additions & 13 deletions bin/node-lambda
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const SRC_DIRECTORY = process.env.SRC_DIRECTORY || ''
const DEPLOY_TIMEOUT = process.env.DEPLOY_TIMEOUT || 120000
const DOCKER_IMAGE = process.env.DOCKER_IMAGE || ''
const DEPLOY_ZIPFILE = process.env.DEPLOY_ZIPFILE || ''
const AWS_DLQ_TARGET_ARN = (function () {
const AWS_DLQ_TARGET_ARN = (() => {
// You can clear the setting by passing an empty string
// when executing updateFunctionConfiguration
if (process.env.AWS_DLQ_TARGET_ARN !== undefined) {
Expand Down Expand Up @@ -93,9 +93,7 @@ program
.option('-T, --deployTimeout [' + DEPLOY_TIMEOUT + ']', 'Deploy Timeout', DEPLOY_TIMEOUT)
.option('-z, --deployZipfile [' + DEPLOY_ZIPFILE + ']', 'Deploy zipfile', DEPLOY_ZIPFILE)
.option('-y, --proxy [' + PROXY + ']', 'Proxy server', PROXY)
.action(function (prg) {
lambda.deploy(prg)
})
.action((prg) => lambda.deploy(prg))

program
.command('package')
Expand All @@ -112,9 +110,7 @@ program
.option('-f, --configFile [' + CONFIG_FILE + ']',
'Path to file holding secret environment variables (e.g. "deploy.env")', CONFIG_FILE)
.option('-D, --prebuiltDirectory [' + PREBUILT_DIRECTORY + ']', 'Prebuilt directory', PREBUILT_DIRECTORY)
.action(function (prg) {
lambda.package(prg)
})
.action((prg) => lambda.package(prg))

program
.command('run')
Expand All @@ -127,18 +123,14 @@ program
.option('-f, --configFile [' + CONFIG_FILE + ']',
'Path to file holding secret environment variables (e.g. "deploy.env")', CONFIG_FILE)
.option('-x, --contextFile [' + CONTEXT_FILE + ']', 'Context JSON File', CONTEXT_FILE)
.action(function (prg) {
lambda.run(prg)
})
.action((prg) => lambda.run(prg))

program
.command('setup')
.description('Sets up the .env file.')
.option('-j, --eventFile [' + EVENT_FILE + ']', 'Event JSON File', EVENT_FILE)
.option('-x, --contextFile [' + CONTEXT_FILE + ']', 'Context JSON File', CONTEXT_FILE)
.action(function (prg) {
lambda.setup(prg)
})
.action((prg) => lambda.setup(prg))

program.parse(process.argv)

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// For development/testing purposes
exports.handler = function (event, context, callback) {
exports.handler = (event, context, callback) => {
console.log('Running index.handler')
console.log('==================================')
console.log('event', event)
Expand Down
14 changes: 6 additions & 8 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Lambda = function () {
return this
}

Lambda.prototype._createSampleFile = function (file, boilerplateName) {
Lambda.prototype._createSampleFile = (file, boilerplateName) => {
const exampleFile = path.join(process.cwd(), file)
const boilerplateFile = path.join(
__dirname,
Expand Down Expand Up @@ -149,7 +149,7 @@ so you can easily test run multiple events.
})
}

Lambda.prototype._params = function (program, buffer) {
Lambda.prototype._params = (program, buffer) => {
const params = {
FunctionName: program.functionName +
(program.environment ? '-' + program.environment : '') +
Expand Down Expand Up @@ -208,14 +208,14 @@ Lambda.prototype._params = function (program, buffer) {
return params
}

Lambda.prototype._eventSourceList = function (program) {
Lambda.prototype._eventSourceList = (program) => {
if (!program.eventSourceFile) {
return {
EventSourceMappings: null,
ScheduleEvents: null
}
}
const list = (function () {
const list = (() => {
try {
return fs.readJsonSync(program.eventSourceFile)
} catch (err) {
Expand Down Expand Up @@ -420,9 +420,7 @@ Lambda.prototype._zip = (program, codeDirectory) => {
})
}

Lambda.prototype._codeDirectory = function () {
return path.resolve('.', '.lambda')
}
Lambda.prototype._codeDirectory = () => path.resolve('.', '.lambda')

Lambda.prototype._cleanDirectory = (codeDirectory) => {
return new Promise((resolve, reject) => {
Expand All @@ -440,7 +438,7 @@ Lambda.prototype._cleanDirectory = (codeDirectory) => {
})
}

Lambda.prototype._setRunTimeEnvironmentVars = function (program) {
Lambda.prototype._setRunTimeEnvironmentVars = (program) => {
const configValues = fs.readFileSync(program.configFile)
const config = dotenv.parse(configValues)

Expand Down
Loading

0 comments on commit 0ad8016

Please sign in to comment.