Socket
Socket
Sign inDemoInstall

chalk

Package Overview
Dependencies
6
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

46

index.js

@@ -8,2 +8,3 @@ 'use strict';

var defineProps = Object.defineProperties;
var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM);

@@ -16,18 +17,6 @@ function Chalk(options) {

// use bright blue on Windows as the normal blue color is illegible
if (process.platform === 'win32') {
if (isSimpleWindowsTerm) {
ansiStyles.blue.open = '\u001b[94m';
}
function build(_styles) {
var builder = function builder() {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
builder.enabled = this.enabled;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
builder.__proto__ = proto;
return builder;
}
var styles = (function () {

@@ -51,2 +40,17 @@ var ret = {};

function build(_styles) {
var builder = function builder() {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
builder.enabled = this.enabled;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
/*eslint no-proto: 0 */
builder.__proto__ = proto;
return builder;
}
function applyStyle() {

@@ -57,2 +61,3 @@ // support varags, but simply cast to string in case there's only one arg

var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {

@@ -69,8 +74,16 @@ // don't slice `arguments`, it prevents v8 optimizations

/*jshint validthis: true */
var nestedStyles = this._styles;
var i = nestedStyles.length;
var i = nestedStyles.length;
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
// see https://github.com/chalk/chalk/issues/58
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
var originalDim = ansiStyles.dim.open;
if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) {
ansiStyles.dim.open = '';
}
while (i--) {
var code = ansiStyles[nestedStyles[i]];
// Replace any instances already present with a re-opening code

@@ -82,2 +95,5 @@ // otherwise only the part of the string until said closing code

// Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue.
ansiStyles.dim.open = originalDim;
return str;

@@ -84,0 +100,0 @@ }

{
"name": "chalk",
"version": "1.0.0",
"version": "1.1.0",
"description": "Terminal string styling done right. Much color.",
"license": "MIT",
"repository": "sindresorhus/chalk",
"repository": "chalk/chalk",
"maintainers": [
"Sindre Sorhus <sindresorhus@gmail.com> (http://sindresorhus.com)",
"Joshua Appelman <jappelman@xebia.com> (http://jbnicolai.com)"
"Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
"Joshua Appelman <jappelman@xebia.com> (jbnicolai.com)"
],

@@ -16,3 +16,5 @@ "engines": {

"test": "mocha",
"bench": "matcha benchmark.js"
"bench": "matcha benchmark.js",
"coverage": "nyc npm test && nyc report",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls"
},

@@ -30,3 +32,5 @@ "files": [

"string",
"str",
"ansi",
"style",
"styles",

@@ -45,12 +49,17 @@ "tty",

"dependencies": {
"ansi-styles": "^2.0.1",
"ansi-styles": "^2.1.0",
"escape-string-regexp": "^1.0.2",
"has-ansi": "^1.0.3",
"strip-ansi": "^2.0.1",
"supports-color": "^1.3.0"
"has-ansi": "^2.0.0",
"strip-ansi": "^3.0.0",
"supports-color": "^2.0.0"
},
"devDependencies": {
"coveralls": "^2.11.2",
"matcha": "^0.6.0",
"mocha": "*"
"mocha": "*",
"nyc": "^3.0.0",
"require-uncached": "^1.0.2",
"resolve-from": "^1.0.0",
"semver": "^4.3.3"
}
}
<h1 align="center">
<br>
<img width="360" src="https://cdn.rawgit.com/sindresorhus/chalk/19935d6484811c5e468817f846b7b3d417d7bf4a/logo.svg" alt="chalk">
<br>
<img width="360" src="https://cdn.rawgit.com/chalk/chalk/19935d6484811c5e468817f846b7b3d417d7bf4a/logo.svg" alt="chalk">
<br>
<br>
<br>
</h1>

@@ -10,4 +12,7 @@

[![Build Status](https://travis-ci.org/sindresorhus/chalk.svg?branch=master)](https://travis-ci.org/sindresorhus/chalk) [![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg?style=flat)](https://www.youtube.com/watch?v=Sm368W0OsHo)
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk)
[![Coverage Status](https://coveralls.io/repos/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/r/chalk/chalk?branch=master)
[![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4)
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68). Although there are other ones, they either do too much or not enough.

@@ -17,3 +22,3 @@

![screenshot](https://github.com/sindresorhus/ansi-styles/raw/master/screenshot.png)
![](https://github.com/chalk/ansi-styles/raw/master/screenshot.png)

@@ -30,3 +35,3 @@

- Actively maintained
- [Used by ~3000 modules](https://www.npmjs.com/browse/depended/chalk)
- [Used by ~4000 modules](https://www.npmjs.com/browse/depended/chalk) as of May 24, 2015

@@ -110,3 +115,3 @@

Detect whether the terminal [supports color](https://github.com/sindresorhus/supports-color). Used internally and handled for you, but exposed for convenience.
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.

@@ -117,3 +122,3 @@ Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.

Exposes the styles as [ANSI escape codes](https://github.com/sindresorhus/ansi-styles).
Exposes the styles as [ANSI escape codes](https://github.com/chalk/ansi-styles).

@@ -133,7 +138,7 @@ Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with your own.

Check whether a string [has color](https://github.com/sindresorhus/has-ansi).
Check whether a string [has color](https://github.com/chalk/has-ansi).
### chalk.stripColor(string)
[Strip color](https://github.com/sindresorhus/strip-ansi) from a string.
[Strip color](https://github.com/chalk/strip-ansi) from a string.

@@ -201,4 +206,14 @@ Can be useful in combination with `.supportsColor` to strip color on externally styled text when it's not supported.

## Related
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
- [ansi-styles](https://github.com/chalk/ansi-styles/) - ANSI escape codes for styling strings in the terminal
- [supports-color](https://github.com/chalk/supports-color/) - Detect whether a terminal supports color
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc