diff --git a/bin/index.js b/bin/index.js index 97b9334a7310c..cfa4b5f60eb8e 100644 --- a/bin/index.js +++ b/bin/index.js @@ -1,6 +1,9 @@ /*eslint-disable */ var program = require('commander') var packageJson = require('../package.json') +var _ = require('lodash') +var subCmd +var cmds /*eslint-enable */ program @@ -9,3 +12,11 @@ program .command('build [directory]', 'Do a production build of site') .command('new [rootPath] [starter]', 'Create new Gatsby project in path [.].') .parse(process.argv) + +// If the user types an unknown sub-command, just display the help. +subCmd = _.head(program.args) +cmds = _.map(program.commands, '_name') + +if (!_.includes(cmds, subCmd)) { + program.help() +}