Skip to content

Commit 0ad8016

Browse files
abetomoDeviaVir
authored andcommitted
Replace with arrow function (#342)
* 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
1 parent 0d144c8 commit 0ad8016

File tree

4 files changed

+62
-83
lines changed

4 files changed

+62
-83
lines changed

bin/node-lambda

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const SRC_DIRECTORY = process.env.SRC_DIRECTORY || ''
4343
const DEPLOY_TIMEOUT = process.env.DEPLOY_TIMEOUT || 120000
4444
const DOCKER_IMAGE = process.env.DOCKER_IMAGE || ''
4545
const DEPLOY_ZIPFILE = process.env.DEPLOY_ZIPFILE || ''
46-
const AWS_DLQ_TARGET_ARN = (function () {
46+
const AWS_DLQ_TARGET_ARN = (() => {
4747
// You can clear the setting by passing an empty string
4848
// when executing updateFunctionConfiguration
4949
if (process.env.AWS_DLQ_TARGET_ARN !== undefined) {
@@ -93,9 +93,7 @@ program
9393
.option('-T, --deployTimeout [' + DEPLOY_TIMEOUT + ']', 'Deploy Timeout', DEPLOY_TIMEOUT)
9494
.option('-z, --deployZipfile [' + DEPLOY_ZIPFILE + ']', 'Deploy zipfile', DEPLOY_ZIPFILE)
9595
.option('-y, --proxy [' + PROXY + ']', 'Proxy server', PROXY)
96-
.action(function (prg) {
97-
lambda.deploy(prg)
98-
})
96+
.action((prg) => lambda.deploy(prg))
9997

10098
program
10199
.command('package')
@@ -112,9 +110,7 @@ program
112110
.option('-f, --configFile [' + CONFIG_FILE + ']',
113111
'Path to file holding secret environment variables (e.g. "deploy.env")', CONFIG_FILE)
114112
.option('-D, --prebuiltDirectory [' + PREBUILT_DIRECTORY + ']', 'Prebuilt directory', PREBUILT_DIRECTORY)
115-
.action(function (prg) {
116-
lambda.package(prg)
117-
})
113+
.action((prg) => lambda.package(prg))
118114

119115
program
120116
.command('run')
@@ -127,18 +123,14 @@ program
127123
.option('-f, --configFile [' + CONFIG_FILE + ']',
128124
'Path to file holding secret environment variables (e.g. "deploy.env")', CONFIG_FILE)
129125
.option('-x, --contextFile [' + CONTEXT_FILE + ']', 'Context JSON File', CONTEXT_FILE)
130-
.action(function (prg) {
131-
lambda.run(prg)
132-
})
126+
.action((prg) => lambda.run(prg))
133127

134128
program
135129
.command('setup')
136130
.description('Sets up the .env file.')
137131
.option('-j, --eventFile [' + EVENT_FILE + ']', 'Event JSON File', EVENT_FILE)
138132
.option('-x, --contextFile [' + CONTEXT_FILE + ']', 'Context JSON File', CONTEXT_FILE)
139-
.action(function (prg) {
140-
lambda.setup(prg)
141-
})
133+
.action((prg) => lambda.setup(prg))
142134

143135
program.parse(process.argv)
144136

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// For development/testing purposes
2-
exports.handler = function (event, context, callback) {
2+
exports.handler = (event, context, callback) => {
33
console.log('Running index.handler')
44
console.log('==================================')
55
console.log('event', event)

lib/main.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const Lambda = function () {
2222
return this
2323
}
2424

25-
Lambda.prototype._createSampleFile = function (file, boilerplateName) {
25+
Lambda.prototype._createSampleFile = (file, boilerplateName) => {
2626
const exampleFile = path.join(process.cwd(), file)
2727
const boilerplateFile = path.join(
2828
__dirname,
@@ -149,7 +149,7 @@ so you can easily test run multiple events.
149149
})
150150
}
151151

152-
Lambda.prototype._params = function (program, buffer) {
152+
Lambda.prototype._params = (program, buffer) => {
153153
const params = {
154154
FunctionName: program.functionName +
155155
(program.environment ? '-' + program.environment : '') +
@@ -208,14 +208,14 @@ Lambda.prototype._params = function (program, buffer) {
208208
return params
209209
}
210210

211-
Lambda.prototype._eventSourceList = function (program) {
211+
Lambda.prototype._eventSourceList = (program) => {
212212
if (!program.eventSourceFile) {
213213
return {
214214
EventSourceMappings: null,
215215
ScheduleEvents: null
216216
}
217217
}
218-
const list = (function () {
218+
const list = (() => {
219219
try {
220220
return fs.readJsonSync(program.eventSourceFile)
221221
} catch (err) {
@@ -420,9 +420,7 @@ Lambda.prototype._zip = (program, codeDirectory) => {
420420
})
421421
}
422422

423-
Lambda.prototype._codeDirectory = function () {
424-
return path.resolve('.', '.lambda')
425-
}
423+
Lambda.prototype._codeDirectory = () => path.resolve('.', '.lambda')
426424

427425
Lambda.prototype._cleanDirectory = (codeDirectory) => {
428426
return new Promise((resolve, reject) => {
@@ -440,7 +438,7 @@ Lambda.prototype._cleanDirectory = (codeDirectory) => {
440438
})
441439
}
442440

443-
Lambda.prototype._setRunTimeEnvironmentVars = function (program) {
441+
Lambda.prototype._setRunTimeEnvironmentVars = (program) => {
444442
const configValues = fs.readFileSync(program.configFile)
445443
const config = dotenv.parse(configValues)
446444

0 commit comments

Comments
 (0)