Skip to content

Commit

Permalink
fix: remove args
Browse files Browse the repository at this point in the history
  • Loading branch information
Antony DAVID authored and plantain-00 committed May 30, 2024
1 parent 39ad59f commit 8632142
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ If the plugin does not work, you may see some workarounds:
Yes, This package calls Typescript API, Typescript can parse Javascript file(with `allowJs`), then this package can too.
> Q: How to disable color in output?
Set the environment variable `FORCE_COLOR=0` or use `--no-color` option, see [chalk documentation](https://github.com/chalk/chalk?tab=readme-ov-file#supportscolor) for details.
## Changelogs
[CHANGELOG for minor and patch release](./CHANGELOG.md)
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"minimist": "1",
"type-coverage-core": "^2.28.1",
"chalk": "^4"
"chalk": "4.1.2"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand Down
27 changes: 6 additions & 21 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import minimist = require('minimist')
import chalk = require('chalk')
import * as fs from 'fs'
import * as util from 'util'
import * as path from 'path'

import * as packageJson from '../package.json'
import { lint } from 'type-coverage-core'
import chalk = require('chalk')

let suppressError = false
let jsonOutput = false
Expand All @@ -29,7 +29,6 @@ interface Output {
is?: number
details?: LintResult[]
error?: string | unknown
color?: boolean
}

const output: Output = {
Expand Down Expand Up @@ -75,8 +74,6 @@ function printHelp() {
--not-only-in-cwd boolean? include results outside current working directory
--json-output boolean? output results as JSON
--report-unused-ignore boolean? report unused ignore line directives
--color boolean? force color output
--no-color boolean? disable color output
`)
}

Expand Down Expand Up @@ -120,8 +117,6 @@ interface CliArgs extends BaseArgs {
['cache-directory']: string
['not-only-in-cwd']: boolean
['json-output']: boolean
['color']: boolean
['no-color']: boolean
}

interface PkgArgs extends BaseArgs {
Expand All @@ -146,9 +141,6 @@ interface PkgArgs extends BaseArgs {
cacheDirectory: string
notOnlyInCWD: boolean
jsonOutput: boolean

color: boolean
noColor: boolean
}

interface PackageJson {
Expand Down Expand Up @@ -196,8 +188,7 @@ async function executeCommandLine() {
reportSemanticError,
reportUnusedIgnore,
cacheDirectory,
notOnlyInCWD,
color
notOnlyInCWD
} = await getTarget(argv);

const { correctCount, totalCount, anys } = await lint(project, {
Expand Down Expand Up @@ -246,7 +237,6 @@ async function executeCommandLine() {
output.percent = percent
output.percentString = percentString
output.totalCount = totalCount
output.color = color

if (update) {
await saveTarget(+percentString)
Expand Down Expand Up @@ -321,7 +311,6 @@ async function getTarget(argv: CliArgs) {
const reportUnusedIgnore = getArgOrCfgVal(['report-unused-ignore', 'reportUnusedIgnore'])
const cacheDirectory = getArgOrCfgVal(['cache-directory', 'cacheDirectory'])
const notOnlyInCWD = getArgOrCfgVal(['not-only-in-cwd', 'notOnlyInCWD'])
const color = getArgOrCfgVal(['color', 'color']) || !getArgOrCfgVal(['no-color', 'no-color'])

return {
atLeast,
Expand All @@ -348,8 +337,7 @@ async function getTarget(argv: CliArgs) {
reportSemanticError,
reportUnusedIgnore,
cacheDirectory,
notOnlyInCWD,
color
notOnlyInCWD
};
}

Expand Down Expand Up @@ -394,10 +382,7 @@ async function saveHistory(percentage: number, historyFile?:string) {
}
}

function printOutput(output: Output, asJson: boolean, colors?: boolean) {
if(colors === false) {
chalk.level = 0
}
function printOutput(output: Output, asJson: boolean) {
if(asJson) {
console.log(JSON.stringify(output, null, 2))
return
Expand Down Expand Up @@ -429,7 +414,7 @@ function printOutput(output: Output, asJson: boolean, colors?: boolean) {

executeCommandLine().then(() => {
output.succeeded = true;
printOutput(output, jsonOutput, output.color)
printOutput(output, jsonOutput)
}, (error: Error | string) => {
output.succeeded = false;
if (error instanceof Error) {
Expand All @@ -438,7 +423,7 @@ executeCommandLine().then(() => {
output.error = error
}

printOutput(output, jsonOutput, output.color)
printOutput(output, jsonOutput)

if (!suppressError) {
process.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ callsites@^3.0.0:
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==

chalk@^4, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1:
chalk@4.1.2, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
Expand Down

0 comments on commit 8632142

Please sign in to comment.