Skip to content

Commit

Permalink
Merge pull request #86 from sparksuite/handle-no-arguments
Browse files Browse the repository at this point in the history
Fix help screen not appearing when no arguments
  • Loading branch information
WesCossick authored Mar 29, 2019
2 parents f383b0d + 4b9d358 commit 3cd0319
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
13 changes: 12 additions & 1 deletion test/pizza-ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
});
});
});

0 comments on commit 3cd0319

Please sign in to comment.