diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 3c3629e..239ecff 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +yarn.lock diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.travis.yml b/.travis.yml index 7d69d74..f98fed0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: + - '12' + - '10' - '8' - - '6' - - '4' diff --git a/index.js b/index.js index f6b07e8..8ab64b4 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ 'use strict'; const ansiRegex = require('ansi-regex'); -// Remove the `g` flag -const re = new RegExp(ansiRegex().source); +// Removes the `g` flag +const regex = new RegExp(ansiRegex().source); -module.exports = input => re.test(input); +module.exports = string => regex.test(string); diff --git a/package.json b/package.json index fe9ac06..dacffaf 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,51 @@ { - "name": "has-ansi", - "version": "3.0.0", - "description": "Check if a string has ANSI escape codes", - "license": "MIT", - "repository": "chalk/has-ansi", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "ansi", - "styles", - "color", - "colour", - "colors", - "terminal", - "console", - "string", - "tty", - "escape", - "shell", - "xterm", - "command-line", - "text", - "regex", - "regexp", - "re", - "match", - "test", - "find", - "pattern", - "has" - ], - "dependencies": { - "ansi-regex": "^3.0.0" - }, - "devDependencies": { - "ava": "*", - "xo": "*" - } + "name": "has-ansi", + "version": "3.0.0", + "description": "Check if a string has ANSI escape codes", + "license": "MIT", + "repository": "chalk/has-ansi", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "string", + "tty", + "escape", + "shell", + "xterm", + "command-line", + "text", + "regex", + "regexp", + "match", + "test", + "find", + "pattern", + "has" + ], + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "devDependencies": { + "ava": "^2.3.0", + "xo": "^0.24.0" + } } diff --git a/test.js b/test.js index 26d811d..20db2c1 100644 --- a/test.js +++ b/test.js @@ -1,7 +1,7 @@ import test from 'ava'; -import m from '.'; +import hasAnsi from '.'; -test(t => { - t.true(m('foo\u001B[4mcake\u001B[0m')); - t.false(m('cake')); +test('main', t => { + t.true(hasAnsi('foo\u001B[4mcake\u001B[0m')); + t.false(hasAnsi('cake')); });