Comparing version 1.0.2 to 1.0.3
37
index.js
@@ -7,18 +7,31 @@ /*! | ||
var util = require('util'); | ||
var Chalk = require('chalk').constructor; | ||
module.exports = function sumUp(data) { | ||
if (typeof data !== 'object') { | ||
throw new TypeError('Argument must be an object.'); | ||
module.exports = function sumUp(pkgData) { | ||
if (!pkgData || Array.isArray(pkgData) || typeof pkgData !== 'object') { | ||
throw new TypeError( | ||
util.inspect(pkgData).replace(/\n/g, '') + | ||
' is not a plain object. Expected an object of package information,' + | ||
' for example npm\'s package.json `{name: ... version: ..., description: ..., ...}`.' | ||
); | ||
} | ||
var chalk = new Chalk({enabled: data.color}); | ||
if (pkgData.color !== undefined && typeof pkgData.color !== 'boolean') { | ||
throw new TypeError( | ||
util.inspect(pkgData.color).replace(/\n/g, '') + | ||
' is neither true nor false. `color` option must be a Boolean value.' | ||
); | ||
} | ||
var chalk = new Chalk({enabled: pkgData.color}); | ||
var lines = []; | ||
var nameAndVersion = chalk.cyan(data.name || ''); | ||
if (data.version) { | ||
if (data.name) { | ||
var nameAndVersion = chalk.cyan(pkgData.name || ''); | ||
if (pkgData.version) { | ||
if (pkgData.name) { | ||
nameAndVersion += ' '; | ||
} | ||
nameAndVersion += chalk.gray('v' + data.version); | ||
nameAndVersion += chalk.gray('v' + pkgData.version); | ||
} | ||
@@ -30,8 +43,8 @@ | ||
if (data.homepage) { | ||
lines.push(chalk.gray(data.homepage)); | ||
if (pkgData.homepage) { | ||
lines.push(chalk.gray(pkgData.homepage)); | ||
} | ||
if (data.description) { | ||
lines.push(data.description); | ||
if (pkgData.description) { | ||
lines.push(pkgData.description); | ||
} | ||
@@ -38,0 +51,0 @@ |
{ | ||
"name": "sum-up", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Summarize package information", | ||
@@ -9,5 +9,5 @@ "repository": "shinnn/sum-up", | ||
"scripts": { | ||
"pretest": "eslint --config node_modules/@shinnn/eslintrc-node/rc.json index.js test.js", | ||
"test": "node test.js --color && node test.js --no-color", | ||
"coverage": "istanbul cover test.js -- --color", | ||
"pretest": "eslint --config @shinnn/node-legacy 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" | ||
@@ -36,8 +36,7 @@ }, | ||
"devDependencies": { | ||
"@shinnn/eslintrc-node": "^1.0.2", | ||
"eslint": "^0.22.1", | ||
"istanbul": "^0.3.15", | ||
"istanbul-coveralls": "^1.0.3", | ||
"tape": "^4.0.0" | ||
"@shinnn/eslint-config-node-legacy": "^2.0.0", | ||
"eslint": "^2.4.0", | ||
"istanbul": "^0.4.2", | ||
"tape": "^4.5.1" | ||
} | ||
} |
@@ -5,6 +5,5 @@ # sum-up | ||
[![Build Status](https://travis-ci.org/shinnn/sum-up.svg?branch=master)](https://travis-ci.org/shinnn/sum-up) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/75fo71xq2sc86tnv?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/sum-up) | ||
[![Coverage Status](https://img.shields.io/coveralls/shinnn/sum-up.svg)](https://coveralls.io/r/shinnn/sum-up) | ||
[![Dependency Status](https://img.shields.io/david/shinnn/sum-up.svg?label=deps)](https://david-dm.org/shinnn/sum-up) | ||
[![devDependency Status](https://img.shields.io/david/dev/shinnn/sum-up.svg?label=devDeps)](https://david-dm.org/shinnn/sum-up#info=devDependencies) | ||
[![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) | ||
@@ -66,4 +65,4 @@ Summarize package information | ||
Copyright (c) 2014 - 2015 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
Copyright (c) 2014 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
Licensed under [the MIT License](./LICENSE). |
Sorry, the diff of this file is not supported yet
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
5222
4
41
67