From f342ea0f43e84a42c8c82bd8802d03165cc293c7 Mon Sep 17 00:00:00 2001 From: "Eslam A. Hefnawy" Date: Tue, 8 Dec 2015 20:04:53 +0200 Subject: [PATCH] added function name to event.json --- lib/actions/ModuleCreate.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/actions/ModuleCreate.js b/lib/actions/ModuleCreate.js index 6a57cb6fc..ee716733e 100644 --- a/lib/actions/ModuleCreate.js +++ b/lib/actions/ModuleCreate.js @@ -204,6 +204,8 @@ usage: serverless module create`, let _this = this, writeDeferred = [], + eventJson = {}, + functionName = _this.evt.module.charAt(0).toUpperCase() + _this.evt.module.slice(1) + _this.evt.function.charAt(0).toUpperCase() + _this.evt.function.slice(1), moduleJsonTemplate = _this._generateModuleJson(), functionJsonTemplate = _this._generateFunctionJson(), packageJsonTemplate = SUtils.readAndParseJsonSync(path.join(_this._templatesDir, 'nodejs', 'package.json')), @@ -226,13 +228,14 @@ usage: serverless module create`, SUtils.writeFile(path.join(_this.evt.modulePath, 'package.json'), JSON.stringify(packageJsonTemplate, null, 2)), SUtils.writeFile(path.join(_this.evt.modulePath, 's-module.json'), JSON.stringify(moduleJsonTemplate, null, 2)) ); - + + eventJson[functionName] = {}; // Write module/function structure writeDeferred.push( fs.mkdirSync(_this.evt.functionPath), SUtils.writeFile(path.join(_this.evt.modulePath, 'lib', 'index.js'), libJs), SUtils.writeFile(path.join(_this.evt.functionPath, 'handler.js'), handlerJs), - SUtils.writeFile(path.join(_this.evt.functionPath, 'event.json'), '{}'), + SUtils.writeFile(path.join(_this.evt.functionPath, 'event.json'), eventJson), SUtils.writeFile(path.join(_this.evt.functionPath, 's-function.json'), JSON.stringify(functionJsonTemplate, null, 2)) );