Skip to content

Commit 56597a9

Browse files
committedDec 12, 2021
Migrate to ESM
1 parent 2c9e06d commit 56597a9

24 files changed

+339
-334
lines changed
 

‎.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"es6": true
66
},
77
"parserOptions": {
8-
"ecmaVersion": 2018
8+
"ecmaVersion": 2018,
9+
"sourceType": "module"
910
},
1011
"rules": {
1112
"no-duplicate-case": 2,

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Allowed args after and between options
44
- Replaced `chalk` with `ansi-colors`
5+
- Migrated to ESM
56

67
## 3.0.0-beta.1
78

‎lib/command.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const getCommandHelp = require('./help');
2-
const parseArgv = require('./parse-argv');
3-
const Params = require('./params');
4-
const Option = require('./option');
1+
import getCommandHelp from './help.js';
2+
import parseArgv from './parse-argv.js';
3+
import Params from './params.js';
4+
import Option from './option.js';
55

66
const noop = () => {}; // nothing todo
77
const self = value => value;
@@ -20,7 +20,7 @@ const handlers = ['init', 'applyConfig', 'finishContext', 'action'].reduce((res,
2020
return res;
2121
}, { initial: {}, setters: {} });
2222

23-
module.exports = class Command {
23+
export default class Command {
2424
constructor(usage = '') {
2525
const [name, params] = usage.trim().split(/(\s+.*)$/);
2626

‎lib/help.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const colors = require('ansi-colors');
1+
import colors from 'ansi-colors';
22

33
const MAX_LINE_WIDTH = process.stdout.columns || 200;
44
const MIN_OFFSET = 20;
@@ -115,7 +115,7 @@ function optionsHelp(command) {
115115
* @return {String}
116116
* @api private
117117
*/
118-
module.exports = function getCommandHelp(command, commandPath) {
118+
export default function getCommandHelp(command, commandPath) {
119119
commandPath = Array.isArray(commandPath) && commandPath.length
120120
? commandPath.concat(command.name).join(' ')
121121
: command.name;

‎lib/index.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
const path = require('path');
2-
const Params = require('./params');
3-
const Option = require('./option');
4-
const Command = require('./command');
5-
const Error = require('./parse-argv-error');
6-
const getCommandHelp = require('./help');
1+
import { basename, extname } from 'path';
2+
import Params from './params.js';
3+
import Option from './option.js';
4+
import Command from './command.js';
5+
import Error from './parse-argv-error.js';
6+
import getCommandHelp from './help.js';
77

88
function nameFromProcessArgv() {
9-
return path.basename(process.argv[1], path.extname(process.argv[1]));
9+
return basename(process.argv[1], extname(process.argv[1]));
1010
}
1111

12-
module.exports = {
12+
function command(name, params, config) {
13+
name = name || nameFromProcessArgv() || 'command';
14+
15+
return new Command(name, params, config);
16+
}
17+
18+
export {
1319
Error,
1420
Params,
1521
Command,
1622
Option,
1723

1824
getCommandHelp,
19-
command: function(name, params, config) {
20-
name = name || nameFromProcessArgv() || 'command';
21-
22-
return new Command(name, params, config);
23-
}
25+
command
2426
};

‎lib/option.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
const Params = require('./params');
1+
import Params from './params.js';
2+
23
const camelcase = name => name.replace(/-(.)/g, (m, ch) => ch.toUpperCase());
34
const ensureFunction = (fn, fallback) => typeof fn === 'function' ? fn : fallback;
45
const self = value => value;
56

6-
module.exports = class Option {
7+
export default class Option {
78
static normalizeOptions(opt1, opt2) {
89
const raw = typeof opt1 === 'function'
910
? { normalize: opt1, default: opt2 }

‎lib/params.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = class Params {
1+
export default class Params {
22
constructor(params = '', context) {
33
// params = ..<required> ..[optional]
44
// <foo> - required

‎lib/parse-argv-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = class CliError extends Error {
1+
export default class CliError extends Error {
22
constructor(...args) {
33
super(...args);
44
this.name = 'CliError';

‎lib/parse-argv.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const CliError = require('./parse-argv-error');
1+
import CliError from './parse-argv-error.js';
22

33
function findVariants(command, entry) {
44
return [
@@ -47,7 +47,7 @@ function consumeOptionParams(option, rawOptions, argv, index, suggestPoint) {
4747
return index + tokens.length - 1;
4848
}
4949

50-
module.exports = function parseArgv(command, argv, context, suggestMode) {
50+
export default function parseArgv(command, argv, context, suggestMode) {
5151
const suggestPoint = suggestMode ? argv.length - 1 : -1;
5252
const rawOptions = [];
5353
const result = {

‎package.json

+8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@
1313
"argument",
1414
"completion"
1515
],
16+
"type": "module",
1617
"main": "lib/index.js",
18+
"exports": {
19+
".": {
20+
"import": "./lib/index.js",
21+
"require": "./cjs/index.cjs"
22+
},
23+
"./package.json": "./package.json"
24+
},
1725
"files": [
1826
"lib"
1927
],

‎test/command-action.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { equal, notDeepEqual, deepEqual } from 'assert';
2+
import * as clap from 'clap';
33

4-
describe('action()', function() {
5-
it('should have an expected input', function() {
4+
describe('action()', () => {
5+
it('should have an expected input', () => {
66
const calls = [];
7-
const command = cli
8-
.command('test [foo]')
7+
const command = clap.command('test [foo]')
98
.option('--bar', 'bar option')
10-
.action(function(...args) {
9+
.action((...args) => {
1110
calls.push({
1211
this: this,
1312
arguments: args
@@ -16,9 +15,9 @@ describe('action()', function() {
1615

1716
command.run(['abc', '--', 'rest', 'args']);
1817

19-
assert.equal(calls.length, 1);
20-
assert.notDeepEqual(calls[0].this, command);
21-
assert.deepEqual(calls[0].arguments, [{
18+
equal(calls.length, 1);
19+
notDeepEqual(calls[0].this, command);
20+
deepEqual(calls[0].arguments, [{
2221
commandPath: ['test'],
2322
options: { bar: false },
2423
args: ['abc'],

‎test/command-args-and-options.js

+35-35
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepStrictEqual, throws, equal } from 'assert';
2+
import * as clap from 'clap';
33

4-
describe('command run', function() {
4+
describe('command run', () => {
55
describe('args and options', () => {
66
let command;
77

8-
beforeEach(function() {
9-
command = cli.command('test [foo]')
8+
beforeEach(() => {
9+
command = clap.command('test [foo]')
1010
.option('--foo', 'Foo')
1111
.option('--bar <number>', 'Bar', Number);
1212
});
1313

14-
it('no arguments', function() {
14+
it('no arguments', () => {
1515
const actual = command.run([]);
1616

17-
assert.deepStrictEqual(actual, {
17+
deepStrictEqual(actual, {
1818
commandPath: ['test'],
1919
options: {
2020
__proto__: null,
@@ -25,10 +25,10 @@ describe('command run', function() {
2525
});
2626
});
2727

28-
it('args', function() {
28+
it('args', () => {
2929
const actual = command.run(['qux']);
3030

31-
assert.deepStrictEqual(actual, {
31+
deepStrictEqual(actual, {
3232
commandPath: ['test'],
3333
options: {
3434
__proto__: null,
@@ -39,10 +39,10 @@ describe('command run', function() {
3939
});
4040
});
4141

42-
it('options', function() {
42+
it('options', () => {
4343
const actual = command.run(['--foo', '--bar', '123']);
4444

45-
assert.deepStrictEqual(actual, {
45+
deepStrictEqual(actual, {
4646
commandPath: ['test'],
4747
options: {
4848
__proto__: null,
@@ -54,10 +54,10 @@ describe('command run', function() {
5454
});
5555
});
5656

57-
it('literal args', function() {
57+
it('literal args', () => {
5858
const actual = command.run(['--', '--one', '--two', '123']);
5959

60-
assert.deepStrictEqual(actual, {
60+
deepStrictEqual(actual, {
6161
commandPath: ['test'],
6262
options: {
6363
__proto__: null,
@@ -68,10 +68,10 @@ describe('command run', function() {
6868
});
6969
});
7070

71-
it('args & options', function() {
71+
it('args & options', () => {
7272
const actual = command.run(['qux', '--foo', '--bar', '123']);
7373

74-
assert.deepStrictEqual(actual, {
74+
deepStrictEqual(actual, {
7575
commandPath: ['test'],
7676
options: {
7777
__proto__: null,
@@ -83,10 +83,10 @@ describe('command run', function() {
8383
});
8484
});
8585

86-
it('args & options before', function() {
86+
it('args & options before', () => {
8787
const actual = command.run(['--foo', '--bar', '123', 'qux']);
8888

89-
assert.deepStrictEqual(actual, {
89+
deepStrictEqual(actual, {
9090
commandPath: ['test'],
9191
options: {
9292
__proto__: null,
@@ -98,10 +98,10 @@ describe('command run', function() {
9898
});
9999
});
100100

101-
it('args & literal args', function() {
101+
it('args & literal args', () => {
102102
const actual = command.run(['qux', '--', '--one', '--two', '123']);
103103

104-
assert.deepStrictEqual(actual, {
104+
deepStrictEqual(actual, {
105105
commandPath: ['test'],
106106
options: {
107107
__proto__: null,
@@ -112,10 +112,10 @@ describe('command run', function() {
112112
});
113113
});
114114

115-
it('options & literal args', function() {
115+
it('options & literal args', () => {
116116
const actual = command.run(['--foo', '--bar', '123', '--', '--one', '--two', '123']);
117117

118-
assert.deepStrictEqual(actual, {
118+
deepStrictEqual(actual, {
119119
commandPath: ['test'],
120120
options: {
121121
__proto__: null,
@@ -127,10 +127,10 @@ describe('command run', function() {
127127
});
128128
});
129129

130-
it('args & options & literal args', function() {
130+
it('args & options & literal args', () => {
131131
const actual = command.run(['qux', '--foo', '--bar', '123', '--', '--one', '--two', '123']);
132132

133-
assert.deepStrictEqual(actual, {
133+
deepStrictEqual(actual, {
134134
commandPath: ['test'],
135135
options: {
136136
__proto__: null,
@@ -145,12 +145,12 @@ describe('command run', function() {
145145

146146
describe('multi arg option', () => {
147147
it('x', () => {
148-
const command = cli.command()
148+
const command = clap.command()
149149
.option('--option <arg1> [arg2]', 'description', function(value, oldValue) {
150150
return (oldValue || []).concat(value);
151151
});
152152

153-
assert.deepStrictEqual(
153+
deepStrictEqual(
154154
command.run(['--option','foo', 'bar', '--option', 'baz']).options,
155155
{
156156
__proto__: null,
@@ -162,36 +162,36 @@ describe('command run', function() {
162162

163163
describe('required argument', () => {
164164
let action;
165-
const command = cli
165+
const command = clap
166166
.command('test <arg1>')
167167
.action(() => action = '1')
168168
.command('nested <arg2>')
169169
.action(() => action = '2')
170170
.end();
171171

172-
beforeEach(function() {
172+
beforeEach(() => {
173173
action = '';
174174
});
175175

176-
it('should throw exception if no first argument', function() {
177-
assert.throws(
176+
it('should throw exception if no first argument', () => {
177+
throws(
178178
() => command.run([]),
179179
/Missed required argument\(s\) for command "test"/
180180
);
181181
});
182-
it('should throw exception if no second argument', function() {
183-
assert.throws(
182+
it('should throw exception if no second argument', () => {
183+
throws(
184184
() => command.run(['one', 'nested']),
185185
/Missed required argument\(s\) for command "nested"/
186186
);
187187
});
188-
it('should treat first argument as value', function() {
188+
it('should treat first argument as value', () => {
189189
command.run(['nested']);
190-
assert.equal(action, '1');
190+
equal(action, '1');
191191
});
192-
it('should run nested action', function() {
192+
it('should run nested action', () => {
193193
command.run(['one', 'nested', 'two']);
194-
assert.equal(action, '2');
194+
equal(action, '2');
195195
});
196196
});
197197
});

‎test/command-clone.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepEqual, notStrictEqual, notDeepEqual } from 'assert';
2+
import { command as cli } from 'clap';
33

44
describe('Command#clone()', () => {
55
let command;
66
let clone;
77

88
beforeEach(() => {
9-
command = cli
10-
.command('test')
9+
command = cli('test')
1110
.description('test')
1211
.option('--test-option', 'xxx')
1312
.command('foo')
@@ -17,50 +16,50 @@ describe('Command#clone()', () => {
1716
});
1817

1918
it('should be deep equal, but dictionaries should not be the same', () => {
20-
assert.deepEqual(clone, command);
21-
assert.notStrictEqual(clone.commands, command.commands);
22-
assert.notStrictEqual(clone.options, command.options);
19+
deepEqual(clone, command);
20+
notStrictEqual(clone.commands, command.commands);
21+
notStrictEqual(clone.options, command.options);
2322
});
2423

2524
it('should be deep equal if set the same version', () => {
2625
command.version('1.1.1');
27-
assert.notDeepEqual(clone, command);
26+
notDeepEqual(clone, command);
2827

2928
clone.version('1.1.1');
30-
assert.deepEqual(clone, command);
29+
deepEqual(clone, command);
3130
});
3231

3332
it('should be deep equal if add the same option', () => {
3433
command.option('--extra', 'zzz');
35-
assert.notDeepEqual(clone, command);
34+
notDeepEqual(clone, command);
3635

3736
clone.option('--extra', 'zzz');
38-
assert.deepEqual(clone, command);
37+
deepEqual(clone, command);
3938
});
4039

4140
it('should be deep equal if add the same subcommand', () => {
4241
command.command('bar').option('--abc', 'aaa');
43-
assert.notDeepEqual(clone, command);
42+
notDeepEqual(clone, command);
4443

4544
clone.command('bar').option('--abc', 'aaa');
46-
assert.deepEqual(clone.commands.bar, command.commands.bar);
45+
deepEqual(clone.commands.bar, command.commands.bar);
4746
});
4847

4948
it('should be deep equal if add the same option to nested command with deep cloning', () => {
5049
clone = command.clone(true);
5150

5251
command.getCommand('foo').option('--extra', 'zzz');
53-
assert.notDeepEqual(clone, command);
52+
notDeepEqual(clone, command);
5453

5554
clone.getCommand('foo').option('--extra', 'zzz');
56-
assert.deepEqual(clone, command);
55+
deepEqual(clone, command);
5756
});
5857

5958
it('should apply handlers as expected', () => {
6059
const actual = clone
6160
.run(['--test-option']);
6261

63-
assert.deepEqual(actual.options, {
62+
deepEqual(actual.options, {
6463
testOption: true
6564
});
6665
});

‎test/command-createOptionValues.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepStrictEqual } from 'assert';
2+
import * as clap from 'clap';
33

4-
describe('createOptionValues()', function() {
5-
it('boolean option', function() {
6-
const command = cli.command()
4+
describe('createOptionValues()', () => {
5+
it('boolean option', () => {
6+
const command = clap.command()
77
.option('--option', 'description', Boolean);
88

9-
assert.deepStrictEqual(
9+
deepStrictEqual(
1010
command.createOptionValues({ option: 'bad value' }),
1111
{
1212
__proto__: null,
@@ -15,13 +15,13 @@ describe('createOptionValues()', function() {
1515
);
1616
});
1717

18-
it('number option', function() {
19-
const command = cli.command()
18+
it('number option', () => {
19+
const command = clap.command()
2020
.option('--option <arg>', 'description', function(value) {
2121
return isNaN(value) ? 0 : value;
2222
}, 1);
2323

24-
assert.deepStrictEqual(
24+
deepStrictEqual(
2525
command.createOptionValues({ option: 'bad value' }),
2626
{
2727
__proto__: null,
@@ -30,13 +30,13 @@ describe('createOptionValues()', function() {
3030
);
3131
});
3232

33-
it('multi arg option', function() {
34-
const command = cli.command()
33+
it('multi arg option', () => {
34+
const command = clap.command()
3535
.option('--option <arg1> [arg2]', 'description', function(value, oldValue) {
3636
return (oldValue || []).concat(value);
3737
});
3838

39-
assert.deepStrictEqual(
39+
deepStrictEqual(
4040
command.createOptionValues({ option: ['foo', 'bar'] }),
4141
{
4242
__proto__: null,
@@ -45,11 +45,11 @@ describe('createOptionValues()', function() {
4545
);
4646
});
4747

48-
it('option with no default value and argument should be set', function() {
49-
const command = cli.command()
48+
it('option with no default value and argument should be set', () => {
49+
const command = clap.command()
5050
.option('--option <value>');
5151

52-
assert.deepStrictEqual(
52+
deepStrictEqual(
5353
command.createOptionValues({ option: 'ok' }),
5454
{
5555
__proto__: null,
@@ -58,24 +58,24 @@ describe('createOptionValues()', function() {
5858
);
5959
});
6060

61-
it('should ignore unknown keys', function() {
62-
const command = cli.command()
61+
it('should ignore unknown keys', () => {
62+
const command = clap.command()
6363
.option('--option <value>');
6464

65-
assert.deepStrictEqual(
65+
deepStrictEqual(
6666
command.createOptionValues({ foo: 'ok' }),
6767
Object.create(null)
6868
);
6969
});
7070

71-
it('general test', function() {
72-
const command = cli.command()
71+
it('general test', () => {
72+
const command = clap.command()
7373
.option('--foo <value>', '', Number)
7474
.option('--bar [value]')
7575
.option('--with-default [x]', '', { default: 'default' })
7676
.option('--bool');
7777

78-
assert.deepStrictEqual(
78+
deepStrictEqual(
7979
command.createOptionValues({
8080
foo: '123',
8181
option: 'ok'

‎test/command-extend.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepEqual } from 'assert';
2+
import * as clap from 'clap';
33

44
describe('Command#extend()', () => {
55
it('basic', () => {
@@ -8,8 +8,7 @@ describe('Command#extend()', () => {
88
invocations.push(args);
99
};
1010

11-
const command = cli
12-
.command('test')
11+
const command = clap.command('test')
1312
.extend(extension, 1, 2);
1413
const nested = command
1514
.command('nested')
@@ -18,7 +17,7 @@ describe('Command#extend()', () => {
1817

1918
command.extend(extension, 2, 3);
2019

21-
assert.deepEqual(invocations, [
20+
deepEqual(invocations, [
2221
[command, 1, 2],
2322
[nested],
2423
[nested, 1, 2, 3, 4],

‎test/command-help.js

+18-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
const assert = require('assert');
2-
const stdout = require('test-console').stdout;
3-
const cli = require('../lib');
1+
import { strictEqual, equal } from 'assert';
2+
import { stdout } from 'test-console';
3+
import * as clap from 'clap';
44

55
describe('Command help', () => {
66
let inspect;
77
beforeEach(() => inspect = stdout.inspect());
88
afterEach(() => inspect.restore());
99

10-
it('should remove default help when .help(false)', function() {
11-
const command = cli.command('test').help(false);
10+
it('should remove default help when .help(false)', () => {
11+
const command = clap.command('test').help(false);
1212

13-
assert.strictEqual(command.getOption('help'), null);
13+
strictEqual(command.getOption('help'), null);
1414
});
1515

1616
it('should show help', () => {
17-
cli.command('test', false).run(['--help']);
17+
clap.command('test', false).run(['--help']);
1818

19-
assert.equal(inspect.output, [
19+
equal(inspect.output, [
2020
'Usage:',
2121
'',
2222
' \u001b[36mtest\u001b[39m [\u001b[33moptions\u001b[39m]',
@@ -29,13 +29,13 @@ describe('Command help', () => {
2929
].join('\n'));
3030
});
3131

32-
it('help with no short options', function() {
33-
cli.command('test', false, { defaultHelp: false })
32+
it('help with no short options', () => {
33+
clap.command('test', false, { defaultHelp: false })
3434
.help('--help')
3535
.option('--foo', 'Foo')
3636
.run(['--help']);
3737

38-
assert.equal(inspect.output, [
38+
equal(inspect.output, [
3939
'Usage:',
4040
'',
4141
' \u001b[36mtest\u001b[39m [\u001b[33moptions\u001b[39m]',
@@ -50,8 +50,7 @@ describe('Command help', () => {
5050
});
5151

5252
it('should show help all cases', () => {
53-
cli
54-
.command('test [qux]')
53+
clap.command('test [qux]')
5554
.description('Test description')
5655
.option('-f, --foo', 'Foo')
5756
.option('--bar <baz>', 'Bar', 8080)
@@ -62,7 +61,7 @@ describe('Command help', () => {
6261
.end()
6362
.run(['--help']);
6463

65-
assert.equal(inspect.output, [
64+
equal(inspect.output, [
6665
'Test description',
6766
'',
6867
'Usage:',
@@ -85,15 +84,14 @@ describe('Command help', () => {
8584
});
8685

8786
it('should show help for nested command', () => {
88-
cli
89-
.command('test [qux]')
87+
clap.command('test [qux]')
9088
.option('-f, --foo', 'Foo')
9189
.command('nested [nested-arg]')
9290
.option('--bar <baz>', 'Bar')
9391
.end()
9492
.run(['nested', '--help']);
9593

96-
assert.equal(inspect.output, [
94+
equal(inspect.output, [
9795
'Usage:',
9896
'',
9997
' \u001b[36mtest nested\u001b[39m \u001b[35m[nested-arg]\u001b[39m [\u001b[33moptions\u001b[39m]',
@@ -107,14 +105,13 @@ describe('Command help', () => {
107105
].join('\n'));
108106
});
109107

110-
it('should show help message when Command#outputHelp called', function() {
111-
const command = cli
112-
.command('test [qux]')
108+
it('should show help message when Command#outputHelp called', () => {
109+
const command = clap.command('test [qux]')
113110
.option('-f, --foo', 'Foo');
114111

115112
command.outputHelp();
116113

117-
assert.equal(inspect.output, [
114+
equal(inspect.output, [
118115
'Usage:',
119116
'',
120117
' \u001b[36mtest\u001b[39m \u001b[35m[qux]\u001b[39m [\u001b[33moptions\u001b[39m]',

‎test/command-parse-handlers.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepEqual } from 'assert';
2+
import * as clap from 'clap';
33

4-
describe('init()/applyConfig()/finishContext()', function() {
4+
describe('init()/applyConfig()/finishContext()', () => {
55
let command;
66
let calls;
77

8-
beforeEach(function() {
8+
beforeEach(() => {
99
calls = [];
10-
command = cli.command('test [arg1]')
10+
command = clap.command('test [arg1]')
1111
.init(() => calls.push('init'))
1212
.applyConfig(() => calls.push('applyConfig'))
1313
.finishContext(() => calls.push('finishContext'));
@@ -17,18 +17,18 @@ describe('init()/applyConfig()/finishContext()', function() {
1717
.finishContext(() => calls.push('nested finishContext'));
1818
});
1919

20-
it('with no arguments should init/finishContext top level command only', function() {
20+
it('with no arguments should init/finishContext top level command only', () => {
2121
command.run([]);
22-
assert.deepEqual(calls, ['init', 'applyConfig', 'finishContext']);
22+
deepEqual(calls, ['init', 'applyConfig', 'finishContext']);
2323
});
2424

25-
it('with one argument should init and finishContext top level command', function() {
25+
it('with one argument should init and finishContext top level command', () => {
2626
command.run(['foo']);
27-
assert.deepEqual(calls, ['init', 'applyConfig', 'finishContext']);
27+
deepEqual(calls, ['init', 'applyConfig', 'finishContext']);
2828
});
2929

30-
it('with first argument as command should init/finishContext both commands', function() {
30+
it('with first argument as command should init/finishContext both commands', () => {
3131
command.run(['nested']);
32-
assert.deepEqual(calls, ['init', 'applyConfig', 'finishContext', 'nested init', 'nested applyConfig', 'nested finishContext']);
32+
deepEqual(calls, ['init', 'applyConfig', 'finishContext', 'nested init', 'nested applyConfig', 'nested finishContext']);
3333
});
3434
});

‎test/command-shortcut-option.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepEqual } from 'assert';
2+
import * as clap from 'clap';
33

44
describe('Command#shortcutOption()', () => {
55
it('basic', () => {
6-
const command = cli.command('test')
6+
const command = clap.command('test')
77
.option('--foo [foo]', 'Foo', Number)
88
.option('--no-bar', 'Bar')
99
.option('--baz [x]', 'Baz', {
@@ -17,15 +17,15 @@ describe('Command#shortcutOption()', () => {
1717
}
1818
});
1919

20-
assert.deepEqual(command.run([]).options, {
20+
deepEqual(command.run([]).options, {
2121
bar: true
2222
});
23-
assert.deepEqual(command.run(['--baz', '5']).options, {
23+
deepEqual(command.run(['--baz', '5']).options, {
2424
bar: true,
2525
baz: '55',
2626
foo: 55
2727
});
28-
assert.deepEqual(command.run(['--baz', '0']).options, {
28+
deepEqual(command.run(['--baz', '0']).options, {
2929
bar: false,
3030
baz: '00',
3131
foo: 0

‎test/command-version.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
const assert = require('assert');
2-
const stdout = require('test-console').stdout;
3-
const cli = require('../lib');
1+
import { equal } from 'assert';
2+
import { stdout } from 'test-console';
3+
import * as clap from 'clap';
44

5-
describe('command run', function() {
5+
describe('command run', () => {
66
let inspect;
77
beforeEach(() => inspect = stdout.inspect());
88
afterEach(() => inspect.restore());
99

1010
it('should output version when specified', () => {
11-
cli
12-
.command('test', false)
11+
clap.command('test', false)
1312
.version('1.2.3')
1413
.run(['--version']);
1514

16-
assert.equal(inspect.output, '1.2.3\n');
15+
equal(inspect.output, '1.2.3\n');
1716
});
1817
});

‎test/names.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import assert, { notStrictEqual, throws, strictEqual } from 'assert';
2+
import * as clap from 'clap';
33

4-
describe('names', function() {
5-
it('bool option should be in values, options and long', function() {
6-
const command = cli.command()
4+
describe('names', () => {
5+
it('bool option should be in values, options and long', () => {
6+
const command = clap.command()
77
.option('--bool');
88

99
assert([...command.options.keys()], ['--bool', 'bool']);
10-
assert.notStrictEqual(command.getOption('--bool'), null);
11-
assert.notStrictEqual(command.getOption('bool'), null);
10+
notStrictEqual(command.getOption('--bool'), null);
11+
notStrictEqual(command.getOption('bool'), null);
1212
});
1313

14-
it('inverted bool option should be in values and options as normal name and as is in long', function() {
15-
const command = cli.command()
14+
it('inverted bool option should be in values and options as normal name and as is in long', () => {
15+
const command = clap.command()
1616
.option('--no-bool');
1717

1818
assert([...command.options.keys()], ['--no-bool', 'bool']);
19-
assert.notStrictEqual(command.getOption('--no-bool'), null);
20-
assert.notStrictEqual(command.getOption('bool'), null);
19+
notStrictEqual(command.getOption('--no-bool'), null);
20+
notStrictEqual(command.getOption('bool'), null);
2121
});
2222

23-
it('dasherized option should store as camelName in options', function() {
24-
const command = cli.command()
23+
it('dasherized option should store as camelName in options', () => {
24+
const command = clap.command()
2525
.option('--bool-option');
2626

2727
assert([...command.options.keys()], ['--bool-option', 'boolOption']);
28-
assert.notStrictEqual(command.getOption('--bool-option'), null);
29-
assert.notStrictEqual(command.getOption('boolOption'), null);
28+
notStrictEqual(command.getOption('--bool-option'), null);
29+
notStrictEqual(command.getOption('boolOption'), null);
3030
});
3131

32-
it('non-bool option should have name as is', function() {
33-
const command = cli.command()
32+
it('non-bool option should have name as is', () => {
33+
const command = clap.command()
3434
.option('--no-bool <arg>');
3535

3636
assert([...command.options.keys()], ['--no-bool', 'noBool']);
37-
assert.notStrictEqual(command.getOption('--no-bool'), null);
38-
assert.notStrictEqual(command.getOption('noBool'), null);
37+
notStrictEqual(command.getOption('--no-bool'), null);
38+
notStrictEqual(command.getOption('noBool'), null);
3939
});
4040

41-
it('should be exception if no long form', function() {
42-
assert.throws(
43-
() => cli.command().option('-b'),
41+
it('should be exception if no long form', () => {
42+
throws(
43+
() => clap.command().option('-b'),
4444
/Usage has no long name: -b/
4545
);
4646
});
4747

48-
it('#getOption() should not resolve option name by long form', function() {
49-
const command = cli.command()
48+
it('#getOption() should not resolve option name by long form', () => {
49+
const command = clap.command()
5050
.option('--long-form');
5151

52-
assert.strictEqual(command.getOption('long-form'), null);
52+
strictEqual(command.getOption('long-form'), null);
5353
});
5454

55-
it('#getOption() should resolve option name by camelName', function() {
56-
const command = cli.command()
55+
it('#getOption() should resolve option name by camelName', () => {
56+
const command = clap.command()
5757
.option('--long-form');
5858

59-
assert.notStrictEqual(command.getOption('longForm'), null);
59+
notStrictEqual(command.getOption('longForm'), null);
6060
});
6161
});

‎test/option-bool.js

+35-35
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { strictEqual, throws } from 'assert';
2+
import * as clap from 'clap';
33

4-
describe('boolean options', function() {
5-
describe('positive', function() {
6-
it('should be false by default', function() {
7-
const command = cli.command()
4+
describe('boolean options', () => {
5+
describe('positive', () => {
6+
it('should be false by default', () => {
7+
const command = clap.command()
88
.option('--bool');
99

1010
const { options } = command.run([]);
11-
assert.strictEqual(options.bool, false);
11+
strictEqual(options.bool, false);
1212
});
1313

14-
it('should throw an exception if oposite option defined already', function() {
15-
assert.throws(
16-
() => cli.command()
14+
it('should throw an exception if oposite option defined already', () => {
15+
throws(
16+
() => clap.command()
1717
.option('--no-bool')
1818
.option('--bool'),
1919
/Option name "bool" already in use by --no-bool/
2020
);
2121
});
2222

23-
it('should be true if option present', function() {
24-
const command = cli.command()
23+
it('should be true if option present', () => {
24+
const command = clap.command()
2525
.option('--bool');
2626

2727
const { options } = command.run(['--bool']);
28-
assert.strictEqual(options.bool, true);
28+
strictEqual(options.bool, true);
2929
});
3030

31-
it('should throw an exception for inverted option', function() {
32-
const command = cli.command()
31+
it('should throw an exception for inverted option', () => {
32+
const command = clap.command()
3333
.option('--bool');
3434

35-
assert.throws(
35+
throws(
3636
() => command.run(['--no-bool']),
3737
/Unknown option: --no-bool/
3838
);
3939
});
4040

41-
it('normalize function result should be ignored', function() {
42-
const command = cli.command()
41+
it('normalize function result should be ignored', () => {
42+
const command = clap.command()
4343
.option('--bool', 'description', () => false);
4444

4545
const { options } = command.run(['--bool']);
46-
assert.strictEqual(options.bool, true);
46+
strictEqual(options.bool, true);
4747
});
4848
});
4949

5050

51-
describe('negative', function() {
52-
it('should be true by default', function() {
53-
const command = cli.command()
51+
describe('negative', () => {
52+
it('should be true by default', () => {
53+
const command = clap.command()
5454
.option('--no-bool');
5555

5656
const { options } = command.run([]);
57-
assert.strictEqual(options.bool, true);
57+
strictEqual(options.bool, true);
5858
});
5959

60-
it('should throw an exception if oposite option defined already', function() {
61-
assert.throws(
62-
() => cli.command()
60+
it('should throw an exception if oposite option defined already', () => {
61+
throws(
62+
() => clap.command()
6363
.option('--bool')
6464
.option('--no-bool'),
6565
/Option name "bool" already in use by --bool/
6666
);
6767
});
6868

69-
it('should be false if option present', function() {
70-
const command = cli.command()
69+
it('should be false if option present', () => {
70+
const command = clap.command()
7171
.option('--no-bool');
7272

7373
const { options } = command.run(['--no-bool']);
74-
assert.strictEqual(options.bool, false);
74+
strictEqual(options.bool, false);
7575
});
7676

77-
it('should throw an exception for non-inverted option', function() {
78-
const command = cli.command()
77+
it('should throw an exception for non-inverted option', () => {
78+
const command = clap.command()
7979
.option('--no-bool');
8080

81-
assert.throws(
81+
throws(
8282
() => command.run(['--bool']),
8383
/Unknown option: --bool/
8484
);
8585
});
8686

87-
it('normalize function result should be ignored', function() {
88-
const command = cli.command()
87+
it('normalize function result should be ignored', () => {
88+
const command = clap.command()
8989
.option('--no-bool', 'description', () => true);
9090

9191
const { options } = command.run(['--no-bool']);
92-
assert.strictEqual(options.bool, false);
92+
strictEqual(options.bool, false);
9393
});
9494
});
9595
});

‎test/option-one-arg.js

+67-67
Original file line numberDiff line numberDiff line change
@@ -1,197 +1,197 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepEqual, notStrictEqual, strictEqual, throws, deepStrictEqual, doesNotThrow } from 'assert';
2+
import * as clap from 'clap';
33

4-
describe('one arg options', function() {
5-
describe('required param', function() {
6-
it('should not be in values by default', function() {
7-
const command = cli.command()
4+
describe('one arg options', () => {
5+
describe('required param', () => {
6+
it('should not be in values by default', () => {
7+
const command = clap.command()
88
.option('--option <arg>');
99

1010
const { options } = command.run([]);
11-
assert.deepEqual(options, Object.create(null));
12-
assert.notStrictEqual(command.getOption('option'), null);
11+
deepEqual(options, Object.create(null));
12+
notStrictEqual(command.getOption('option'), null);
1313
});
1414

15-
it('should store default value', function() {
16-
const command = cli.command()
15+
it('should store default value', () => {
16+
const command = clap.command()
1717
.option('--option <arg>', 'description', 123);
1818

1919
const { options } = command.run([]);
20-
assert.strictEqual(options.option, 123);
20+
strictEqual(options.option, 123);
2121
});
2222

23-
it('default value should be wrapped by normalize function', function() {
24-
const command = cli.command()
23+
it('default value should be wrapped by normalize function', () => {
24+
const command = clap.command()
2525
.option('--option <arg>', 'description', value => value * 2, 123);
2626

2727
const { options } = command.run([]);
28-
assert.strictEqual(options.option, 246);
28+
strictEqual(options.option, 246);
2929
});
3030

31-
it('should not be in values when normalize function preset but no default value', function() {
32-
const command = cli.command()
33-
.option('--option <arg>', 'description', function() {
31+
it('should not be in values when normalize function preset but no default value', () => {
32+
const command = clap.command()
33+
.option('--option <arg>', 'description', () => {
3434
return 123;
3535
});
3636

3737
const { options } = command.run([]);
38-
assert.deepEqual(options, Object.create(null));
38+
deepEqual(options, Object.create(null));
3939
});
4040

41-
it('should read only one argument', function() {
41+
it('should read only one argument', () => {
4242
let ok = false;
4343
let values;
4444

45-
const command = cli.command()
45+
const command = clap.command()
4646
.option('--option <arg>', 'description')
4747
.finishContext(({ options }) => values = options)
4848
.command('test')
4949
.action(() => ok = true)
5050
.end();
5151

5252
command.run(['--option', '1', 'test']);
53-
assert.strictEqual(values.option, '1');
54-
assert.strictEqual(ok, true);
53+
strictEqual(values.option, '1');
54+
strictEqual(ok, true);
5555
});
5656

57-
it('should ignore commands', function() {
57+
it('should ignore commands', () => {
5858
let ok = true;
59-
const command = cli.command()
59+
const command = clap.command()
6060
.option('--option <arg>', 'description')
6161
.command('test')
6262
.action(() => ok = false)
6363
.end();
6464

6565
const { options } = command.run(['--option', 'test']);
66-
assert.strictEqual(ok, true);
67-
assert.strictEqual(options.option, 'test');
66+
strictEqual(ok, true);
67+
strictEqual(options.option, 'test');
6868
});
6969

70-
it('should be exception if arg is not specified (no more arguments)', function() {
71-
const command = cli.command()
70+
it('should be exception if arg is not specified (no more arguments)', () => {
71+
const command = clap.command()
7272
.option('--option <arg>', 'description');
7373

74-
assert.throws(
74+
throws(
7575
() => command.run(['--option']),
7676
/Option --option should be used with at least 1 argument\(s\)/
7777
);
7878
});
7979

80-
it('should be exception if arg is not specified (another option next)', function() {
81-
const command = cli.command()
80+
it('should be exception if arg is not specified (another option next)', () => {
81+
const command = clap.command()
8282
.option('--test')
8383
.option('--option <arg>', 'description');
8484

85-
assert.throws(
85+
throws(
8686
() => command.run(['--option', '--test']),
8787
/Option --option should be used with at least 1 argument\(s\)/
8888
);
8989
});
9090

91-
it('#setValue should normalizenew value', function() {
92-
const command = cli.command()
91+
it('#setValue should normalizenew value', () => {
92+
const command = clap.command()
9393
.option('--option <arg>', 'description', value => value * 2);
9494

9595
const { options } = command.run([]);
9696
options.option = 123;
97-
assert.strictEqual(options.option, 246);
97+
strictEqual(options.option, 246);
9898
});
9999
});
100100

101-
describe('optional param', function() {
102-
it('should not be in values by default', function() {
103-
const command = cli.command()
101+
describe('optional param', () => {
102+
it('should not be in values by default', () => {
103+
const command = clap.command()
104104
.option('--option [arg]');
105105

106106
const { options } = command.run([]);
107-
assert.deepEqual(options, Object.create(null));
108-
assert.notStrictEqual(command.getOption('option'), null);
107+
deepEqual(options, Object.create(null));
108+
notStrictEqual(command.getOption('option'), null);
109109
});
110110

111-
it('should store default value', function() {
112-
const command = cli.command()
111+
it('should store default value', () => {
112+
const command = clap.command()
113113
.option('--option [arg]', 'description', 123);
114114

115115
const actual = command.run([]);
116-
assert.strictEqual(actual.options.option, 123);
116+
strictEqual(actual.options.option, 123);
117117
});
118118

119-
it('default value should be wrapped by normalize function', function() {
120-
const command = cli.command()
119+
it('default value should be wrapped by normalize function', () => {
120+
const command = clap.command()
121121
.option('--option [arg]', 'description', function(value) {
122122
return value * 2;
123123
}, 123);
124124

125125
const actual = command.run([]);
126-
assert.strictEqual(actual.options.option, 246);
126+
strictEqual(actual.options.option, 246);
127127
});
128128

129-
it('should not be in values when normalize function preset but no default value', function() {
130-
const command = cli.command()
131-
.option('--option [arg]', 'description', function() {
129+
it('should not be in values when normalize function preset but no default value', () => {
130+
const command = clap.command()
131+
.option('--option [arg]', 'description', () => {
132132
return 123;
133133
});
134134

135135
const actual = command.run([]);
136-
assert.deepStrictEqual(actual.options, Object.create(null));
136+
deepStrictEqual(actual.options, Object.create(null));
137137
});
138138

139-
it('should read only one argument', function() {
139+
it('should read only one argument', () => {
140140
let ok = false;
141141
let values;
142142

143-
const command = cli.command()
143+
const command = clap.command()
144144
.option('--option [arg]', 'description')
145145
.finishContext(({ options }) => values = options)
146146
.command('test')
147147
.action(() => ok = true)
148148
.end();
149149

150150
command.run(['--option', '1', 'test']);
151-
assert.strictEqual(ok, true);
152-
assert.strictEqual(values.option, '1');
151+
strictEqual(ok, true);
152+
strictEqual(values.option, '1');
153153
});
154154

155-
it('should ignore commands', function() {
155+
it('should ignore commands', () => {
156156
let ok = true;
157157

158-
const command = cli.command()
158+
const command = clap.command()
159159
.option('--option [arg]', 'description')
160160
.command('test')
161161
.action(() => ok = false)
162162
.end();
163163

164164
const { options } = command.run(['--option', 'test']);
165-
assert.strictEqual(ok, true);
166-
assert.strictEqual(options.option, 'test');
165+
strictEqual(ok, true);
166+
strictEqual(options.option, 'test');
167167
});
168168

169-
it('should not be exception if arg is not specified (no more arguments)', function() {
170-
const command = cli.command()
169+
it('should not be exception if arg is not specified (no more arguments)', () => {
170+
const command = clap.command()
171171
.option('--option [arg]', 'description');
172172

173-
assert.doesNotThrow(function() {
173+
doesNotThrow(() => {
174174
command.run(['--option']);
175175
});
176176
});
177177

178-
it('should not be exception if arg is not specified (another option next)', function() {
179-
const command = cli.command()
178+
it('should not be exception if arg is not specified (another option next)', () => {
179+
const command = clap.command()
180180
.option('--test')
181181
.option('--option [arg]', 'description');
182182

183-
assert.doesNotThrow(function() {
183+
doesNotThrow(() => {
184184
command.run(['--option', '--test']);
185185
});
186186
});
187187

188-
it('set value to options should normalize new value', function() {
189-
const command = cli.command()
188+
it('set value to options should normalize new value', () => {
189+
const command = clap.command()
190190
.option('--option [arg]', 'description', value => value * 2);
191191

192192
const { options } = command.run([]);
193193
options.option = 123;
194-
assert.strictEqual(options.option, 246);
194+
strictEqual(options.option, 246);
195195
});
196196
});
197197
});

‎test/option-short.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepEqual, throws } from 'assert';
2+
import * as clap from 'clap';
33

44
describe('short options', function() {
55
describe('sequence of boolean options', function() {
6-
const command = cli.command('test')
6+
const command = clap.command('test')
77
.option('-f, --foo', 'Foo')
88
.option('-b, --bar', 'Bar')
99
.option('-x, --baz', 'Baz')
@@ -19,19 +19,19 @@ describe('short options', function() {
1919
].forEach(testcase =>
2020
it(testcase.test, () => {
2121
const actual = command.run([testcase.test]);
22-
assert.deepEqual(testcase.expected, actual.options);
22+
deepEqual(testcase.expected, actual.options);
2323
})
2424
);
2525
});
2626

2727
describe('should throws when unknown short', function() {
28-
const command = cli.command('test')
28+
const command = clap.command('test')
2929
.option('-f, --foo', 'Foo')
3030
.option('-b, --bar', 'Bar');
3131

3232
['-z', '-fz', '-fbz'].forEach((test) => {
3333
it(test, () =>
34-
assert.throws(
34+
throws(
3535
() => command.run(['-fz']),
3636
/Unknown option "z" in short option sequence: -fz/
3737
)
@@ -40,15 +40,15 @@ describe('short options', function() {
4040
});
4141

4242
it('should throws when non-boolean in sequence', function() {
43-
const command = cli.command('test')
43+
const command = clap.command('test')
4444
.option('-f, --foo', 'Foo')
4545
.option('-b, --bar <asd>', 'Bar');
4646

47-
assert.throws(
47+
throws(
4848
() => command.run(['-fb']),
4949
/Non-boolean option "-b" can't be used in short option sequence: -fb/
5050
);
51-
assert.throws(
51+
throws(
5252
() => command.run(['-bf']),
5353
/Non-boolean option "-b" can't be used in short option sequence: -bf/
5454
);

‎test/suggest.js

+35-36
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const assert = require('assert');
2-
const cli = require('../lib');
1+
import { deepEqual } from 'assert';
2+
import * as clap from 'clap';
33

4-
describe('suggest', function() {
4+
describe('suggest', () => {
55
function getSuggestions(startWith) {
66
return all.filter(name => name.startsWith(startWith)).sort();
77
}
@@ -17,8 +17,7 @@ describe('suggest', function() {
1717
];
1818

1919
/* eslint-disable indent */
20-
const command = cli
21-
.command('test [arg1]')
20+
const command = clap.command('test [arg1]')
2221
.option('-f, --foo', 'foo')
2322
.option('-b, --bar', 'bar')
2423
.option('--required-arg <arg>', 'option with required argument')
@@ -35,58 +34,58 @@ describe('suggest', function() {
3534
.end();
3635
/* eslint-enable indent */
3736

38-
it('should suggest commands and options when no input', function() {
39-
assert.deepEqual(command.parse([], true), getSuggestions(''));
37+
it('should suggest commands and options when no input', () => {
38+
deepEqual(command.parse([], true), getSuggestions(''));
4039
});
4140

42-
it('should suggest options names when one dash', function() {
43-
assert.deepEqual(command.parse(['-'], true), getSuggestions('-'));
41+
it('should suggest options names when one dash', () => {
42+
deepEqual(command.parse(['-'], true), getSuggestions('-'));
4443
});
4544

46-
it('should suggest options names when double dash', function() {
47-
assert.deepEqual(command.parse(['--'], true), getSuggestions('--'));
45+
it('should suggest options names when double dash', () => {
46+
deepEqual(command.parse(['--'], true), getSuggestions('--'));
4847
});
4948

50-
it('should suggest matched options', function() {
51-
assert.deepEqual(command.parse(['--b'], true), getSuggestions('--b'));
49+
it('should suggest matched options', () => {
50+
deepEqual(command.parse(['--b'], true), getSuggestions('--b'));
5251
});
5352

54-
it('should suggest matched commands', function() {
55-
assert.deepEqual(command.parse(['b'], true), getSuggestions('bar'));
53+
it('should suggest matched commands', () => {
54+
deepEqual(command.parse(['b'], true), getSuggestions('bar'));
5655
});
5756

58-
it('should suggest nothing when no matches', function() {
59-
assert.deepEqual(command.parse(['--miss'], true), []);
57+
it('should suggest nothing when no matches', () => {
58+
deepEqual(command.parse(['--miss'], true), []);
6059
});
6160

62-
it('should suggest matched commands and options of subcommands when no input', function() {
63-
assert.deepEqual(command.parse(['bar', ''], true), ['--help', '--test', 'baz', 'qux']);
61+
it('should suggest matched commands and options of subcommands when no input', () => {
62+
deepEqual(command.parse(['bar', ''], true), ['--help', '--test', 'baz', 'qux']);
6463
});
6564

66-
it('should suggest matched commands of subcommands', function() {
67-
assert.deepEqual(command.parse(['bar', 'b'], true), ['baz']);
65+
it('should suggest matched commands of subcommands', () => {
66+
deepEqual(command.parse(['bar', 'b'], true), ['baz']);
6867
});
6968

70-
it('should suggest options of subcommands', function() {
71-
assert.deepEqual(command.parse(['foo', '-'], true), ['--bar', '--baz', '--foo', '--help']);
72-
assert.deepEqual(command.parse(['foo', '--'], true), ['--bar', '--baz', '--foo', '--help']);
69+
it('should suggest options of subcommands', () => {
70+
deepEqual(command.parse(['foo', '-'], true), ['--bar', '--baz', '--foo', '--help']);
71+
deepEqual(command.parse(['foo', '--'], true), ['--bar', '--baz', '--foo', '--help']);
7372
});
7473

75-
it('should suggest matched options of subcommands', function() {
76-
assert.deepEqual(command.parse(['foo', '--b'], true), ['--bar', '--baz']);
74+
it('should suggest matched options of subcommands', () => {
75+
deepEqual(command.parse(['foo', '--b'], true), ['--bar', '--baz']);
7776
});
7877

79-
it('should suggest nothing for option arguments', function() {
80-
assert.deepEqual(command.parse(['--required-arg', ''], true), []);
81-
assert.deepEqual(command.parse(['--required-arg', 'a'], true), []);
82-
assert.deepEqual(command.parse(['--optional-arg', ''], true), []);
83-
assert.deepEqual(command.parse(['--optional-arg', 'a'], true), []);
78+
it('should suggest nothing for option arguments', () => {
79+
deepEqual(command.parse(['--required-arg', ''], true), []);
80+
deepEqual(command.parse(['--required-arg', 'a'], true), []);
81+
deepEqual(command.parse(['--optional-arg', ''], true), []);
82+
deepEqual(command.parse(['--optional-arg', 'a'], true), []);
8483
});
8584

86-
it('should suggest nothing after double dash', function() {
87-
assert.deepEqual(command.parse(['--', ''], true), []);
88-
assert.deepEqual(command.parse(['--', 'a'], true), []);
89-
assert.deepEqual(command.parse(['--', '-'], true), []);
90-
assert.deepEqual(command.parse(['--', '--'], true), []);
85+
it('should suggest nothing after double dash', () => {
86+
deepEqual(command.parse(['--', ''], true), []);
87+
deepEqual(command.parse(['--', 'a'], true), []);
88+
deepEqual(command.parse(['--', '-'], true), []);
89+
deepEqual(command.parse(['--', '--'], true), []);
9190
});
9291
});

0 commit comments

Comments
 (0)
Please sign in to comment.