diff --git a/src/index.js b/src/index.js index 0f0c7ca8..d412e29b 100644 --- a/src/index.js +++ b/src/index.js @@ -58,7 +58,7 @@ module.exports = function Constructor(customSettings) { // Handle --help - if (organizedArguments.flags.includes('help')) { + if (organizedArguments.flags.includes('help') || settings.arguments.length === 0) { // Output process.stdout.write(screens(settings).help()); diff --git a/test/pizza-ordering.js b/test/pizza-ordering.js index d139ec1c..787962ee 100644 --- a/test/pizza-ordering.js +++ b/test/pizza-ordering.js @@ -25,8 +25,13 @@ function runTest(customArguments, stdoutIncludes, stderrIncludes, done) { let stderr = ''; + // Form spawn array + let spawnArray = [entryFile, ...customArguments.split(' ')]; + spawnArray = spawnArray.filter(element => element !== ''); + + // Spawn - const child = spawn('node', [entryFile, ...customArguments.split(' ')]); + const child = spawn('node', spawnArray); // Listeners @@ -95,5 +100,11 @@ describe('Pizza ordering', () => { 'Usage: node entry.js list [flags]', ], undefined, done); }); + + it('Displays help screen when no arguments', (done) => { + runTest('', [ + 'Usage: node entry.js [commands]', + ], undefined, done); + }); }); });