Skip to content

Commit

Permalink
Minor code tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 5, 2018
1 parent d2e0e1e commit 89f8983
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -49,10 +49,10 @@
"yargs-parser": "^10.0.0"
},
"devDependencies": {
"ava": "*",
"ava": "^0.25.0",
"execa": "^0.10.0",
"indent-string": "^3.0.0",
"xo": "*"
"xo": "^0.23.0"
},
"xo": {
"rules": {
Expand Down
32 changes: 16 additions & 16 deletions test.js
Expand Up @@ -2,10 +2,10 @@ import test from 'ava';
import indentString from 'indent-string';
import execa from 'execa';
import pkg from './package';
import m from '.';
import meow from '.';

test('return object', t => {
const cli = m({
const cli = meow({
argv: ['foo', '--foo-bar', '-u', 'cat', '--', 'unicorn', 'cake'],
help: `
Usage
Expand All @@ -28,7 +28,7 @@ test('return object', t => {
});

test('support help shortcut', t => {
const cli = m(`
const cli = meow(`
unicorn
cat
`);
Expand Down Expand Up @@ -67,7 +67,7 @@ test('spawn cli and test input flag', async t => {

// TODO: This fails in Node.js 7.10.0, but not 6 or 4
test.serial.skip('pkg.bin as a string should work', t => { // eslint-disable-line ava/no-skip-test
m({
meow({
pkg: {
name: 'browser-sync',
bin: 'bin/browser-sync.js'
Expand All @@ -78,36 +78,36 @@ test.serial.skip('pkg.bin as a string should work', t => { // eslint-disable-lin
});

test('single character flag casing should be preserved', t => {
t.deepEqual(m({argv: ['-F']}).flags, {F: true});
t.deepEqual(meow({argv: ['-F']}).flags, {F: true});
});

test('type inference', t => {
t.is(m({argv: ['5']}).input[0], '5');
t.is(m({argv: ['5']}, {input: 'string'}).input[0], '5');
t.is(m({
t.is(meow({argv: ['5']}).input[0], '5');
t.is(meow({argv: ['5']}, {input: 'string'}).input[0], '5');
t.is(meow({
argv: ['5'],
inferType: true
}).input[0], 5);
t.is(m({
t.is(meow({
argv: ['5'],
inferType: true,
flags: {foo: 'string'}
}).input[0], 5);
t.is(m({
t.is(meow({
argv: ['5'],
inferType: true,
flags: {
foo: 'string'
}
}).input[0], 5);
t.is(m({
t.is(meow({
argv: ['5'],
input: 'number'
}).input[0], 5);
});

test('booleanDefault: undefined, filter out unset boolean args', t => {
t.deepEqual(m('help', {
t.deepEqual(meow('help', {
argv: ['--foo'],
booleanDefault: undefined,
flags: {
Expand All @@ -129,7 +129,7 @@ test('booleanDefault: undefined, filter out unset boolean args', t => {
});

test('boolean args are false by default', t => {
t.deepEqual(m('help', {
t.deepEqual(meow('help', {
argv: ['--foo'],
flags: {
foo: {
Expand All @@ -151,7 +151,7 @@ test('boolean args are false by default', t => {
});

test('enforces boolean flag type', t => {
const cli = m('', {
const cli = meow('', {
argv: ['--cursor=false'],
flags: {
cursor: {type: 'boolean'}
Expand All @@ -161,7 +161,7 @@ test('enforces boolean flag type', t => {
});

test('accept help and options', t => {
t.deepEqual(m('help', {
t.deepEqual(meow('help', {
argv: ['-f'],
flags: {
foo: {
Expand All @@ -176,7 +176,7 @@ test('accept help and options', t => {
});

test('grouped short-flags work', t => {
const cli = m({
const cli = meow({
argv: ['-cl'],
flags: {
coco: {
Expand Down

0 comments on commit 89f8983

Please sign in to comment.