switch to text-table, fix update arg

This commit is contained in:
silverwind 2018-10-04 07:41:31 +02:00
parent 7308c54d3a
commit 5f850abc43
Signed by: silverwind
GPG Key ID: 2E62B41C93869443
2 changed files with 14 additions and 11 deletions

@ -30,11 +30,13 @@
"chalk": "2.4.1",
"columnify": "1.5.4",
"escape-string-regexp": "1.0.5",
"find-up": "^3.0.0",
"find-up": "3.0.0",
"make-fetch-happen": "4.0.1",
"minimist": "1.2.0",
"npm-package-arg": "6.1.0",
"semver": "5.5.1"
"semver": "5.5.1",
"string-width": "^2.1.1",
"text-table": "0.2.0"
},
"devDependencies": {
"eslint": "5.6.1",

@ -167,7 +167,7 @@ Promise.all(Object.keys(deps).map(name => fetch(buildUrl(name)).then(r => r.json
finish("All packages are up to date.");
}
if (!args.update) {
if (args.update === false) {
finish();
}
@ -239,14 +239,15 @@ function highlightDiff(a, b, added) {
}
function formatDeps() {
return require("columnify")(Object.keys(deps).map(dep => {
return {
"name": dep,
"old": highlightDiff(deps[dep].old, deps[dep].new, false),
"new": highlightDiff(deps[dep].new, deps[dep].old, true),
};
}), {
columnSplitter: " ".repeat(4),
const arr = [["NAME", "OLD", "NEW"]];
for (const [name, versions] of Object.entries(deps)) arr.push([
name,
highlightDiff(versions.old, versions.new, false),
highlightDiff(versions.new, versions.old, true),
]);
return require("text-table")(arr, {
hsep: " ".repeat(4),
stringLength: require("string-width"),
});
}