mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
new action: refactor
This commit is contained in:
parent
3b4d110999
commit
2acd5c31b8
@ -20,6 +20,7 @@ Promise.promisifyAll(fs);
|
||||
*/
|
||||
|
||||
module.exports.run = function(JAWS, action) {
|
||||
console.log(JAWS);
|
||||
var command = new CMD(JAWS, action);
|
||||
return command.run();
|
||||
};
|
||||
@ -94,8 +95,8 @@ CMD.prototype._createSkeleton = Promise.method(function() {
|
||||
|
||||
// Fetch skeleton resources
|
||||
var templatesPath = path.join(__dirname, '..', 'templates');
|
||||
var actionJson = JSON.parse(fs.readFileSync(path.join(templatesPath, 'jaws.json')));
|
||||
|
||||
var actionJson = JSON.parse(fs.readFileSync(path.join(templatesPath, 'awsm.json')));
|
||||
console.log(actionJson);
|
||||
var actionPath = path.join(
|
||||
_this._JAWS._meta.projectRootPath,
|
||||
'back',
|
||||
@ -115,7 +116,7 @@ CMD.prototype._createSkeleton = Promise.method(function() {
|
||||
// Edit jaws.json
|
||||
actionJson.name = _this._action.resource + '-' + _this._action.action;
|
||||
actionJson.lambda.functionName = actionJson.name;
|
||||
actionJson.endpoint.path = _this._action.resource + '/' + _this._action.action;
|
||||
actionJson.apiGateway.path = _this._action.resource + '/' + _this._action.action;
|
||||
|
||||
// Create files for lambda actions
|
||||
switch (_this._action.runtime) {
|
||||
@ -164,7 +165,7 @@ CMD.prototype._createSkeleton = Promise.method(function() {
|
||||
|
||||
// Trim unnecessary JSON
|
||||
if (_this._action.type === 'lambda') {
|
||||
delete actionJson.endpoint;
|
||||
delete actionJson.apiGateway;
|
||||
}
|
||||
|
||||
if (_this._action.type === 'endpoint') {
|
||||
@ -172,6 +173,6 @@ CMD.prototype._createSkeleton = Promise.method(function() {
|
||||
}
|
||||
|
||||
// Write Files
|
||||
writeFilesDeferred.push(utils.writeFile(path.join(actionPath, 'jaws.json'), JSON.stringify(actionJson, null, 2)));
|
||||
writeFilesDeferred.push(utils.writeFile(path.join(actionPath, 'awsm.json'), JSON.stringify(actionJson, null, 2)));
|
||||
return Promise.all(writeFilesDeferred);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user