Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: fixed --help on test command
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 2, 2018
1 parent f8689ea commit 57659f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
19 changes: 11 additions & 8 deletions bin/run
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#!/usr/bin/env node

const undefault = m => m.__esModule === true ? m.default : m
require('ts-node/register')

const fs = require('fs')
const path = require('path')
const dev = fs.existsSync(path.join(__dirname, '../tsconfig.json'))

if (dev) require('ts-node/register')

const Command = undefault(require(`../${dev ? 'src' : 'lib'}`))
const {Command, flags, parse} = require('../src')

class TestCommand extends Command {
constructor(argv, opts) {
super(argv, opts)
this.options = parse(argv, TestCommand)
}

async run() {
const {cli} = require('cli-ux')
cli.info('running test command')
}
}
TestCommand.flags = {
help: flags.help(),
version: flags.version(),
}

TestCommand.run()
13 changes: 2 additions & 11 deletions test/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,11 @@ describe('command', () => {
describe('help', () => {
fancy
.stdout()
.it('--helpflag', async ctx => {
.it('--help', async ctx => {
class CMD extends Command {
static flags = {helpflag: flags.help()}
static flags = {help: flags.help()}
options = parse(this.argv, CMD)
}
await CMD.run(['--helpflag'])
expect(ctx.stdout).to.contain(`USAGE
$ @anycli/command [OPTIONS]`)
})

fancy
.stdout()
.it('--help', async ctx => {
class CMD extends Command {}
await CMD.run(['--help'])
expect(ctx.stdout).to.contain(`USAGE
$ @anycli/command`)
Expand Down

0 comments on commit 57659f6

Please sign in to comment.