Skip to content

Commit

Permalink
All: version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
austencollins committed Dec 9, 2015
1 parent e8b5d31 commit c7e6b06
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
35 changes: 24 additions & 11 deletions lib/actions/FunctionRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FunctionRun extends SPlugin {
if (_this.S.cli.options.nonInteractive) _this.S._interactive = false
}

return _this._getFunction(evt)
return _this._loadFunction(evt)
.bind(_this)
.then(_this._runFunction)
.then(function(evt) {
Expand All @@ -76,10 +76,10 @@ class FunctionRun extends SPlugin {
}

/**
* Get Function
* Load Function
*/

_getFunction(evt) {
_loadFunction(evt) {

let _this = this,
cwd = process.cwd();
Expand Down Expand Up @@ -135,12 +135,25 @@ class FunctionRun extends SPlugin {
});
}

return _this.cliPromptSelectFunctions(cwd, 'Select a function to run: ', false, true)
.then(function(selected) {
evt.function = selected[0];
evt.event = SUtils.readAndParseJsonSync(path.join(cwd, 'event.json'));
return evt;
});
// If interactive and no function name or path provided, show select screen
if (_this.S.cli && _this.S._interactive) {

// Otherwise show select screen
return _this.cliPromptSelectFunctions(cwd, 'Select a function to run: ', false, true)
.then(function (selected) {
evt.function = selected[0];
let eventPath = evt.function.pathFunction.replace('s-function.json', '');
if (fs.existsSync(path.join(eventPath, 'event.json'))) {
evt.event = SUtils.readAndParseJsonSync(path.join(eventPath, 'event.json'));
} else {
evt.event = {};
}
return evt;
});
}

// Otherwise, through error
throw new SError(`No function specified`);
}

/**
Expand All @@ -162,7 +175,7 @@ class FunctionRun extends SPlugin {
// Fire NodeJs subaction
let newEvent = {
function: evt.function,
handler: require(process.cwd() + '/' + handlerParts[0] + '.js')[handlerParts[1]],
handler: require(evt.function.pathFunction.replace('s-function.json', '') + handlerParts[0] + '.js')[handlerParts[1]],
event: evt.event
};

Expand All @@ -174,4 +187,4 @@ class FunctionRun extends SPlugin {
}
}

module.exports = FunctionRun;
module.exports = FunctionRun;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless",
"version": "0.0.6",
"version": "0.0.7",
"engines": {
"node": ">=4.0"
},
Expand Down

0 comments on commit c7e6b06

Please sign in to comment.