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

Commit

Permalink
fix: optionally require chalk
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 5, 2018
1 parent 031007e commit 840676d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1,055 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"bugs": "https://github.com/anycli/parser/issues",
"dependencies": {
"@anycli/screen": "^0.0.3",
"chalk": "^2.3.0",
"lodash": "^4.17.4"
},
"devDependencies": {
Expand All @@ -20,6 +19,7 @@
"@types/node-notifier": "^0.0.28",
"@types/read-pkg": "^3.0.0",
"chai": "^4.1.2",
"chalk": "^2.3.0",
"concurrently": "^3.5.1",
"eslint": "^4.17.0",
"eslint-config-anycli": "^1.3.2",
Expand Down
3 changes: 2 additions & 1 deletion src/deps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// tslint:disable no-implicit-dependencies
import screen = require('@anycli/screen')
import chalk = require('chalk')

Expand All @@ -22,7 +23,7 @@ export const deps = {
get chalk(): typeof chalk.default | undefined {
try {
return fetch('chalk').default
// tslint:disable-next-line
// tslint:disable-next-line no-unused
} catch (err) {}
},
}
Expand Down
6 changes: 2 additions & 4 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import * as Flags from './flags'

let debug: any
try {
// tslint:disable-next-line
if (process.env.CLI_FLAGS_DEBUG !== '1') debug = () => {}
else
// tslint:disable-next-line
debug = require('debug')('cli-flags')
// tslint:disable-next-line no-implicit-dependencies
debug = require('debug')('@anycli/parser')
} catch {
// tslint:disable-next-line
debug = () => {}
}

Expand Down
7 changes: 7 additions & 0 deletions test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,11 @@ See more help with --help`)
expect(out.flags.foo).to.equal(101)
})
})

it('parses multiple flags', () => {
const out = parse(['--foo=a', '--foo', 'b'], {
flags: {foo: flags.string()},
})
expect(out.flags.foo).to.equal('b')
})
})
Loading

0 comments on commit 840676d

Please sign in to comment.