diff --git a/bin/jaws b/bin/jaws index e29b693e7..2913aedc8 100755 --- a/bin/jaws +++ b/bin/jaws @@ -28,7 +28,7 @@ program program .command('new ') .allowUnknownOption() - .description('Make a new "project", "stage", "region", "lambda" or "endpoint"') + .description('Make a new "project", "stage", "region", or "action" [ --lambda | --endpoint | --both ] ') .action(function() { // Parse Args @@ -86,7 +86,7 @@ program } else { // Unknown Type - console.error('Unsupported type ' + type + '. Must be project|region|stage'); + console.error('Unsupported type ' + type + '. Must be project|region|stage|action'); process.exit(1); } diff --git a/lib/commands/new_action.js b/lib/commands/new_action.js index 9e5c9da66..ee2285d42 100644 --- a/lib/commands/new_action.js +++ b/lib/commands/new_action.js @@ -96,6 +96,11 @@ 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'))); + + if (!fs.existsSync(path.join('./jaws.json'))) { + throw new JawsError('Must be in a JAWS project folder.'); + } + var actionPath = path.join( _this._JAWS._meta.projectRootPath, 'back', @@ -170,4 +175,4 @@ CMD.prototype._createSkeleton = Promise.method(function() { // Write Files writeFilesDeferred.push(utils.writeFile(path.join(actionPath, 'jaws.json'), JSON.stringify(actionJson, null, 2))); return Promise.all(writeFilesDeferred); -}); \ No newline at end of file +});