Skip to content

Commit

Permalink
Use modern node built-ins, remove 3rd party dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
antonk52 committed Dec 21, 2024
1 parent fa52043 commit 1154d51
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 44 deletions.
17 changes: 8 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const fetch = require('node-fetch');
const kleur = require('kleur');
const fs = require('node:fs');
const path = require('node:path');
const {styleText} = require('node:util')
const {log} = console;

function program(...args) {
Expand Down Expand Up @@ -40,7 +39,7 @@ function program(...args) {
)
.then(sizes => {
const title = `${pkg.name}'s ${isDev ? 'devD ' : 'd'}ependencies:\n`;
log(kleur.bold(title));
log(styleText('bold', title));

return sizes
.sort((a, b) => a.install.bytes - b.install.bytes)
Expand All @@ -52,7 +51,7 @@ function program(...args) {
return `${name} - api failed`;
}
return `
${kleur.bold(name)} @ ${version}
${styleText('bold', name)} @ ${version}
\tinstall size\t${colorSize(install)}
\tpublish size\t${colorSize(publish)}
`.trim();
Expand All @@ -64,10 +63,10 @@ ${kleur.bold(name)} @ ${version}

function colorSize({bytes, pretty}) {
return bytes > 1048576
? kleur.bold(kleur.red(pretty))
? styleText(['bold', 'red'], pretty)
: bytes > 307200
? kleur.yellow(pretty)
: kleur.green(pretty);
? styleText('yellow', pretty)
: styleText('green', pretty);
}

program(...process.argv.slice(2));
43 changes: 11 additions & 32 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
},
"author": "antonk52",
"license": "MIT",
"dependencies": {
"kleur": "^4.1.4",
"node-fetch": "^2.6.1"
"engines": {
"node": ">=20.12"
}
}

0 comments on commit 1154d51

Please sign in to comment.