Skip to content

Commit

Permalink
Replace colors with chalk due to malicious version of colors
Browse files Browse the repository at this point in the history
The maintainer of colors has purposely introduced an infinite loop
in the latest version of colors. Therefore we need to ditch this
dependency.

cli-table must also be updated in order to get rid of the colors
dependency entirely. There is a PR:
Automattic/cli-table#166
Or maybe an alternative table lib should be considered as well?
  • Loading branch information
draperunner committed Jan 10, 2022
1 parent a5afc47 commit e92cb9a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 22 deletions.
71 changes: 57 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
"chalk": "^4.1.2",
"cli-table": "^0.3.1",
"colors": "^1.1.2",
"yargs": "^17.3.0"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions src/ditched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from "path";
import fs from "fs";
import https from "https";
import CliTable from "cli-table";
import colors from "colors/safe";
import chalk from "chalk";
import yargs from "yargs/yargs";
import { hideBin } from "yargs/helpers";

Expand Down Expand Up @@ -76,9 +76,9 @@ function printInfoTable(

const table = new CliTable({
head: [
colors.gray("Package"),
colors.gray("Last Modified"),
colors.gray("Ditched?"),
chalk.gray("Package"),
chalk.gray("Last Modified"),
chalk.gray("Ditched?"),
],
colWidths: [30, 40, 15],
});
Expand All @@ -96,11 +96,11 @@ function printInfoTable(
? formatTimeSince(modifiedDate)
: "No package info found.";

let ditchedInfo = colors.red("?");
let ditchedInfo = chalk.red("?");
if (modifiedDate) {
ditchedInfo = isDitched(packageInfo, ditchDays)
? colors.red("Yes")
: colors.green("No");
? chalk.red("Yes")
: chalk.green("No");
}

table.push([name, formattedTime, ditchedInfo]);
Expand Down

0 comments on commit e92cb9a

Please sign in to comment.