Skip to content

Instantly share code, notes, and snippets.

@theeye-io
Created November 23, 2016 14:00
Show Gist options
  • Save theeye-io/5327b2cf1a955890dce44b574287f1e0 to your computer and use it in GitHub Desktop.
Save theeye-io/5327b2cf1a955890dce44b574287f1e0 to your computer and use it in GitHub Desktop.
WIN_checkDirectoryFreeSpace.js
var exec = require('child_process').exec;
var dir = process.argv[2];
var limit = process.argv[3];
var cmd = 'powershell -noprofile -command "(ls -r ' + dir + ' |measure -s Length).Sum"';
exec(cmd,function(err,stdout,stderr){
if(err){
console.log(err);
console.log(stderr);
return console.log('failure');
}
var total = parseInt(stdout);
console.log('total occupied ' + total + ' , limit is ' + limit);
var state = (total>limit) ? 'failure':'success';
console.log(state);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment