added function name to event.json

This commit is contained in:
Eslam A. Hefnawy 2015-12-08 20:04:53 +02:00
parent 99e5856dbc
commit f342ea0f43

View File

@ -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))
);