remove chalk dependency
This commit is contained in:
parent
ae5b4ef32e
commit
402c6ed7ba
@ -27,7 +27,6 @@
|
||||
"updates.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"chalk": "2.4.1",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"find-up": "3.0.0",
|
||||
"hosted-git-info": "^2.7.1",
|
||||
|
15
updates.js
15
updates.js
@ -80,8 +80,14 @@ if (args.version) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (args["color"]) process.env.FORCE_COLOR = "1";
|
||||
if (args["no-color"]) process.env.FORCE_COLOR = "0";
|
||||
let useColor = Boolean(process.stdout.isTTY);
|
||||
if (args["color"]) useColor = true;
|
||||
if (args["no-color"]) useColor = false;
|
||||
|
||||
const colors = {
|
||||
green: str => useColor ? `\x1b[0;32m${str}\x1b[0m` : str,
|
||||
red: str => useColor ? `\x1b[0;31m${str}\x1b[0m` : str,
|
||||
};
|
||||
|
||||
const greatest = parseMixedArg(args.greatest);
|
||||
const prerelease = parseMixedArg(args.prerelease);
|
||||
@ -167,7 +173,6 @@ if (!Object.keys(deps).length) {
|
||||
|
||||
const fetch = require("make-fetch-happen");
|
||||
const esc = require("escape-string-regexp");
|
||||
const chalk = require("chalk");
|
||||
const hostedGitInfo = require("hosted-git-info");
|
||||
|
||||
const get = async name => {
|
||||
@ -224,7 +229,7 @@ Promise.all(Object.keys(deps).map(name => get(name))).then(dati => {
|
||||
│ package.json updated │
|
||||
╰────────────────────────╯`;
|
||||
|
||||
finish(chalk.green(msg.substring(1)));
|
||||
finish(colors.green(msg.substring(1)));
|
||||
}).catch(finish);
|
||||
|
||||
function finish(obj, opts) {
|
||||
@ -262,7 +267,7 @@ function finish(obj, opts) {
|
||||
function highlightDiff(a, b, added) {
|
||||
const aParts = a.split(/\./);
|
||||
const bParts = b.split(/\./);
|
||||
const color = chalk[added ? "green" : "red"];
|
||||
const color = colors[added ? "green" : "red"];
|
||||
const versionPartRe = /^[0-9a-zA-Z-.]+$/;
|
||||
let res = "";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user