dylang / space-hogs

Discover surprisingly large directories from the command line.
https://www.npmjs.com/package/space-hogs
MIT License
161 stars 9 forks source link

Windows support #3

Open ghost opened 8 years ago

ghost commented 8 years ago

Thank you for this package, been following your module-request since the start. I was also trying to implement this but never got around to finish it, this seems like a solid solution though!

I took some time to look for a Windows (there are dozens of us) solution and found a sysinternals utility that tries to mimic the du command.

A small problem here is that it returns the actual size of the (child-)directories and not the disk-size of these directories, which leads to different results (see image below, should be ~130MB total (on disk)).

sample

It can return the disk-size, but only for one (the top-level) directory, so I assume there should be an extra loop in the Windows .js util by getting the child-directories and sizes individually.

Any thoughts on this? A dependency too much (.exe)? A loop too many?

dylang commented 8 years ago

Cool, I was a big fan of the sysinternals utilities when I was a Windows user.

I'd rather not require Windows users to install something to make this work.

should be ~130MB total (on disk)).

I wasn't sure if people wanted actual size or how much of the disk was being used. Actual size is a better reflection of how much was downloaded and how much Javascript might be executed, but du defaults to disk size, so I used that.

Do you want to give a node version of du a try to see if it's accurate? I avoided it because I read that it's slower than du on Macs, but I never tested that theory.

ghost commented 8 years ago

I don't think they would need to install something, it's an .exe you could provide with the package (a bit like vol does I think) and use it like ex. exec('../vendor/du.exe').

Do you want to give a node version of du a try

Sure! I'll see if I can try to compare it against the node version of du (.exe vs node du).

ghost commented 8 years ago

@dylang : in follow-up (Sorry it took so terribly long, did not have much time lately :()

I tested in Windows with: du in git bash (no changed code), node du, and the sysinternals du tool (sysinternals and node both take the actual file size). It was not really in-depth, but feels reasonable reliable.

Results showed: node > sysinternals > du in git bash (bigger is faster). I also did the same in Linux and your assumption/theory was correct, native du was significantly faster than alternatives. I think the node version could be a good fall-back for systems that would fail with regular du.