Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch to main & update packages & drop node 4 - 8 support #10

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
.git
examples/
tmp/
dist/
public/
**/vendor*/
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "groupon/node4"
"extends": "groupon"
}
17 changes: 17 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "groupon",
"overrides": [
{
"files": "*.test.js",
"env": {
"mocha": true
}
},
{
"files": "plurals.js",
"rules": {
"no-unused-vars": "off"
}
}
]
}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/yarn.lock
/package-lock.json
node_modules/
npm-debug.log
/tmp
coverage
/.nyc_output
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
language: node_js
node_js:
- 4.6.1
- 6.11.5
- 8.9.0
- 12
- 14
deploy:
- provider: script
script: ./node_modules/.bin/nlm release
skip_cleanup: true
'on':
branch: master
node: 8.9.0
node: 14
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ only to discover that it conflicts with plans the maintainers might have.
The general steps for creating a pull request are:

1. Create a branch for your change.
Always start your branch from the latest `master`.
Always start your branch from the latest `main`.
We often prefix the branch name with our initials, e.g. `jk-a-change`.
1. Run `npm install` to install the dependencies.
1. If you're fixing a bug, be sure to write a test *first*.
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# ndu - Visualize your Node app's disk space usage
# `ndu`
> Visualize your Node app's disk space usage

**Requires node 4+ and `du`. Windows not yet supported.**
**Requires node 10.13+ and `du`. Windows not yet supported.**

`ndu` is a tool for analyzing the size of dependencies in a node.js application.
It's similar to [`disc`](https://npmjs.com/disc), but for server-side
dependencies instead of client-side depedencies.
dependencies instead of client-side dependencies.

When building node.js apps, you can choose from hundreds of thousands of
libraries available on [npm](https://www.npmjs.com/). But sometimes these
Expand Down
19 changes: 9 additions & 10 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ defaultRoot.size = _.sumBy(defaultRoot.children, 'size');

function addParentRefsAndName(node) {
node.name = node.path.split('/').pop();
node.children.forEach(function addToChild(child) {
node.children.forEach(child => {
child.parent = node;
addParentRefsAndName(child);
});
Expand All @@ -121,7 +121,7 @@ function sliceColor(weight, position, depth) {

function formatBytes(byteCount) {
var pretty = bytes(byteCount * 1024);
var pct = Math.round(byteCount / defaultRoot.size * 100);
var pct = Math.round((byteCount / defaultRoot.size) * 100);
return `${pretty} / ${pct}%`;
}

Expand All @@ -134,14 +134,14 @@ function renderWithRoot(rootNode) {
return Math.max.apply(
null,
[node.level].concat(
node.children.map(function findInChild(child) {
node.children.map(child => {
return findMaxLevel(level + 1, child);
})
)
);
})(0, rootNode);

var angleScale = 2 * Math.PI / rootNode.size;
var angleScale = (2 * Math.PI) / rootNode.size;
var sliceSize = HEIGHT / 2 / (maxLevel + 1);
var slicePadding = 2;

Expand Down Expand Up @@ -179,7 +179,7 @@ function renderWithRoot(rootNode) {
.attr('stroke', '#fff')
.on('mouseover', showNodeInfo.bind(null, node))
.on('mouseout', resetNodeInfo)
.on('click', function onNodeClick() {
.on('click', () => {
if (node.children.length < 1) return;

if (node !== rootNode) {
Expand All @@ -190,7 +190,7 @@ function renderWithRoot(rootNode) {
});

var childOffset = offset + node.self;
node.children.forEach(function renderChild(child) {
node.children.forEach(child => {
renderNode(child, childOffset);
childOffset += child.size;
});
Expand All @@ -208,15 +208,14 @@ showNodeInfo = function _showNodeInfo(node) {
segments.unshift('.');
var leaf = segments.pop();
var segmentNode = defaultRoot;
segments.forEach(function handleSegment(segment) {
segments.forEach(segment => {
if (segment !== '.') {
segmentNode = _.find(segmentNode.children, { name: segment });
}
h4
.append('a')
h4.append('a')
.attr('href', '#')
.text(segment)
.on('click', _.partial(renderWithRoot, segmentNode));
.on('click', renderWithRoot.bind(null, segmentNode));
h4.append('span').text('/');
});

Expand Down
11 changes: 3 additions & 8 deletions lib/ndu.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ const childProcess = require('child_process');

function exec(cmd, options) {
return new Promise((resolve, reject) => {
childProcess.exec(
cmd,
options,
(error, stdout) => (error ? reject(error) : resolve(stdout))
childProcess.exec(cmd, options, (error, stdout) =>
error ? reject(error) : resolve(stdout)
);
});
}
Expand Down Expand Up @@ -60,10 +58,7 @@ function processOutput(stdout) {

function calcParentStats(entry) {
// map to parent
const parentPath = entry.path
.split('/')
.slice(0, -1)
.join('/');
const parentPath = entry.path.split('/').slice(0, -1).join('/');
const parent = byPath[parentPath];
if (parent) {
parent.self -= entry.size;
Expand Down
Loading