Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ program
.name(name)
.description(description)
.version(version)
.usage('[options] <path>')
.argument('<path>', 'the partial/dependency path to resolve')
.option('-c, --config <path>', 'location of a RequireJS config file for AMD')
.option('-f, --filename <path>', 'file containing the dependency')
.option('-d, --directory <path>', 'directory containing all files')
.showHelpAfterError()
.parse();

if (program.args.length === 0) {
program.help();
}

const partial = program.args[0];
const { filename, config } = program.opts();

Expand Down
21 changes: 21 additions & 0 deletions test/cli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-env mocha */

'use strict';

const assert = require('assert').strict;
const process = require('process');
const { spawnSync } = require('child_process');
const path = require('path');

const cliPath = path.resolve(__dirname, '..', 'bin', 'cli.js');

describe('lookup-amd CLI', () => {
it('prints error and exits 1 when path argument is missing', () => {
const result = spawnSync(process.execPath, [cliPath], {
encoding: 'utf8'
});

assert.equal(result.status, 1);
assert.match(result.stderr, /error: missing required argument 'path'/);
});
});
Loading