sum-up
Advanced tools
Comparing version 2.0.0 to 3.0.0
43
index.js
@@ -7,12 +7,11 @@ /*! | ||
var util = require('util'); | ||
const Chalk = require('chalk').constructor; | ||
const inspectWithKind = require('inspect-with-kind'); | ||
var Chalk = require('chalk').constructor; | ||
module.exports = function sumUp(pkgData, options) { | ||
if (!pkgData || Array.isArray(pkgData) || typeof pkgData !== 'object') { | ||
throw new TypeError( | ||
util.inspect(pkgData) + | ||
' is not a plain object. Expected an object of package information,' + | ||
' for example npm\'s package.json `{name: ... version: ..., description: ..., ...}`.' | ||
`Expected an object of package information \`{name: ... version: ..., description: ..., ...}\`, but got ${ | ||
inspectWithKind(pkgData) | ||
}.` | ||
); | ||
@@ -23,6 +22,5 @@ } | ||
if (Array.isArray(options) || typeof options !== 'object') { | ||
throw new TypeError( | ||
util.inspect(options) + | ||
' is not a plain object. The second argument of sum-up must be a plain object or undefined.' | ||
); | ||
throw new TypeError(`The second argument of sum-up must be a plain object or undefined, but got ${ | ||
inspectWithKind(options) | ||
}.`); | ||
} | ||
@@ -34,19 +32,20 @@ } else { | ||
if (options.color !== undefined && typeof options.color !== 'boolean') { | ||
throw new TypeError( | ||
util.inspect(options.color) + | ||
' is neither true nor false. `color` option must be a Boolean value.' | ||
); | ||
throw new TypeError(`Expected \`color\` option to be a Boolean value, but got ${ | ||
inspectWithKind(options.color) | ||
}.`); | ||
} | ||
var chalk = new Chalk({enabled: options.color}); | ||
var lines = []; | ||
const chalkOption = {}; | ||
var nameAndVersion = chalk.cyan(pkgData.name || ''); | ||
if (pkgData.version) { | ||
if (pkgData.name) { | ||
nameAndVersion += ' '; | ||
} | ||
nameAndVersion += chalk.gray('v' + pkgData.version); | ||
if (options.color !== undefined) { | ||
chalkOption.enabled = options.color; | ||
} | ||
const chalk = new Chalk(chalkOption); | ||
const lines = []; | ||
const nameAndVersion = `${chalk.cyan(pkgData.name || '')}${ | ||
pkgData.version ? `${pkgData.name ? ' ' : ''}${chalk.gray('v' + pkgData.version)}` : '' | ||
}`; | ||
if (nameAndVersion) { | ||
@@ -53,0 +52,0 @@ lines.push(nameAndVersion); |
{ | ||
"name": "sum-up", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Summarize package information", | ||
@@ -9,6 +9,5 @@ "repository": "shinnn/sum-up", | ||
"scripts": { | ||
"pretest": "eslint --config @shinnn/node-legacy --rule 'complexity: [error, 15]' index.js test.js", | ||
"test": "node --strong_mode test.js --color && node test.js --no-color", | ||
"coverage": "node --strong_mode node_modules/.bin/istanbul cover test.js -- --color", | ||
"coveralls": "${npm_package_scripts_coverage} && istanbul-coveralls" | ||
"pretest": "eslint --fix --format=codeframe index.js test.js", | ||
"test": "node test.js --color && node test.js --no-color", | ||
"coverage": "node node_modules/.bin/istanbul cover test.js -- --color" | ||
}, | ||
@@ -33,10 +32,15 @@ "license": "MIT", | ||
"dependencies": { | ||
"chalk": "^1.0.0" | ||
"chalk": "^2.0.1", | ||
"inspect-with-kind": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"@shinnn/eslint-config-node-legacy": "^2.0.0", | ||
"eslint": "^2.4.0", | ||
"istanbul": "^0.4.2", | ||
"tape": "^4.5.1" | ||
"@shinnn/eslint-config-node": "^4.0.0", | ||
"ansi-styles": "^3.1.0", | ||
"eslint": "^4.2.0", | ||
"istanbul": "^0.4.5", | ||
"tape": "^4.7.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@shinnn/node" | ||
} | ||
} |
@@ -6,4 +6,2 @@ # sum-up | ||
[![Coverage Status](https://img.shields.io/coveralls/shinnn/sum-up.svg)](https://coveralls.io/r/shinnn/sum-up) | ||
[![Dependency Status](https://david-dm.org/shinnn/sum-up.svg)](https://david-dm.org/shinnn/sum-up) | ||
[![devDependency Status](https://david-dm.org/shinnn/sum-up/dev-status.svg)](https://david-dm.org/shinnn/sum-up#info=devDependencies) | ||
@@ -63,4 +61,4 @@ Summarize package information | ||
Copyright (c) 2014 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
Copyright (c) 2014 - 2017 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
Licensed under [the MIT License](./LICENSE). |
Sorry, the diff of this file is not supported yet
5319
2
5
49
63
+ Addedinspect-with-kind@^1.0.2
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedinspect-with-kind@1.0.5(transitive)
+ Addedkind-of@6.0.3(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
Updatedchalk@^2.0.1