Skip to content

Commit

Permalink
util: put ansiTrim into util from outdated
Browse files Browse the repository at this point in the history
Credit: @watilde
Reviewed-By: @othiym23
Reviewed-By: @iarna
PR-URL: npm/npm#14582
Fixes: npm#6756
  • Loading branch information
watilde authored and iarna committed Dec 15, 2016
1 parent 33ca4e6 commit 0209ee5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 1 addition & 6 deletions lib/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var isExtraneous = require('./install/is-extraneous.js')
var recalculateMetadata = require('./install/deps.js').recalculateMetadata
var moduleName = require('./utils/module-name.js')
var output = require('./utils/output.js')
var ansiTrim = require('./utils/ansi-trim')

function uniqName (item) {
return item[0].path + '|' + item[1] + '|' + item[7]
Expand Down Expand Up @@ -149,12 +150,6 @@ function makePretty (p) {
return columns
}

function ansiTrim (str) {
var r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
'\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g')
return str.replace(r, '')
}

function makeParseable (list) {
return list.map(function (p) {
var dep = p[0]
Expand Down
7 changes: 7 additions & 0 deletions lib/utils/ansi-trim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function ansiTrim (str) {
var r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
'\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g')
return str.replace(r, '')
}

module.exports = ansiTrim

0 comments on commit 0209ee5

Please sign in to comment.