Comparing version 2.0.0 to 3.0.0
26
cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
var meow = require('meow'); | ||
var appSize = require('./'); | ||
const meow = require('meow'); | ||
const prettyBytes = require('pretty-bytes'); | ||
const appSize = require('./'); | ||
var cli = meow({ | ||
help: [ | ||
'Examples', | ||
' $ app-size Safari', | ||
' $ app-size /Applications/Safari.app', | ||
' $ app-size com.apple.Safari' | ||
] | ||
}); | ||
const cli = meow(` | ||
Example | ||
$ app-size Safari | ||
$ app-size /Applications/Safari.app | ||
$ app-size com.apple.Safari | ||
`); | ||
@@ -20,7 +19,2 @@ if (!cli.input.length) { | ||
appSize(cli.input[0]) | ||
.then(console.log) | ||
.catch(function (err) { | ||
console.error(err.message); | ||
process.exit(1); | ||
}); | ||
appSize(cli.input[0]).then(res => console.log(prettyBytes(res))); |
32
index.js
'use strict'; | ||
var execFile = require('child_process').execFile; | ||
var fs = require('fs'); | ||
var pify = require('pify'); | ||
var Promise = require('pinkie-promise'); | ||
var appPath = require('app-path'); | ||
const fs = require('fs'); | ||
const appPath = require('app-path'); | ||
const execa = require('execa'); | ||
const pify = require('pify'); | ||
function getSize(path) { | ||
var cmd = 'mdls'; | ||
var args = [ | ||
const getSize = path => { | ||
const cmd = 'mdls'; | ||
const args = [ | ||
'-name', | ||
@@ -17,11 +16,8 @@ 'kMDItemFSSize', | ||
return pify(execFile, Promise)(cmd, args) | ||
.then(function (size) { | ||
return parseInt(size, 10); | ||
}); | ||
} | ||
return execa(cmd, args).then(res => parseInt(res.stdout, 10)); | ||
}; | ||
module.exports = function (app) { | ||
module.exports = app => { | ||
if (process.platform !== 'darwin') { | ||
return Promise.reject(new Error('Only OS X systems are supported')); | ||
return Promise.reject(new Error('Only OS X is supported')); | ||
} | ||
@@ -34,3 +30,3 @@ | ||
return pify(fs.stat)(app) | ||
.then(function (stats) { | ||
.then(stats => { | ||
if (!stats.isDirectory()) { | ||
@@ -42,5 +38,5 @@ return Promise.reject(new Error('Expected an application')); | ||
}) | ||
.catch(function (err) { | ||
.catch(err => { | ||
if (err && err.code === 'ENOENT') { | ||
return pify(appPath, Promise)(app).then(getSize); | ||
return appPath(app).then(getSize); | ||
} | ||
@@ -47,0 +43,0 @@ |
{ | ||
"name": "app-size", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Get an .app's size in byte", | ||
@@ -14,3 +14,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
@@ -34,11 +34,11 @@ "scripts": { | ||
"dependencies": { | ||
"app-path": "^1.0.1", | ||
"app-path": "^2.1.0", | ||
"execa": "^0.3.0", | ||
"meow": "^3.3.0", | ||
"pify": "^2.2.0", | ||
"pinkie-promise": "^1.0.0" | ||
"pretty-bytes": "^3.0.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.2.0", | ||
"xo": "^0.9.0" | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -16,3 +16,3 @@ # app-size [![Build Status](https://travis-ci.org/gillstrom/app-size.svg?branch=master)](https://travis-ci.org/gillstrom/app-size) | ||
```js | ||
var appSize = require('app-size'); | ||
const appSize = require('app-size'); | ||
@@ -45,3 +45,3 @@ appSize('Safari').then(size => { | ||
Examples | ||
Example | ||
$ app-size Safari | ||
@@ -48,0 +48,0 @@ $ app-size /Applications/Safari.app |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
0
3869
52
+ Addedexeca@^0.3.0
+ Addedpretty-bytes@^3.0.1
+ Addedapp-path@2.2.0(transitive)
+ Addedcross-spawn-async@2.2.5(transitive)
+ Addedexeca@0.3.00.4.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addednpm-run-path@1.0.0(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedpath-key@1.0.0(transitive)
+ Addedpretty-bytes@3.0.1(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedpify@^2.2.0
- Removedpinkie-promise@^1.0.0
- Removedapp-path@1.0.2(transitive)
- Removedpinkie@1.0.0(transitive)
- Removedpinkie-promise@1.0.0(transitive)
Updatedapp-path@^2.1.0