Skip to content

Commit

Permalink
use patched output fot neat log
Browse files Browse the repository at this point in the history
  • Loading branch information
okdistribute committed May 20, 2018
1 parent bdfa1fb commit 170a913
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion neat-screen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var neatLog = require('neat-log')
var output = require('neat-log/output')
var output = require('./output')
var strftime = require('strftime')
var Commander = require('./commands.js')
var chalk = require('chalk')
Expand Down
19 changes: 19 additions & 0 deletions output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = trim

function trim (s) {
if (!/^\r?\n/.test(s)) return s
return deindent(s)
}

function deindent (s) {
if (!/^\r?\n/.test(s)) return s
var indent = (s.match(/\n([ ]+)/m) || [])[1] || ''
s = indent + s
return s.split('\n')
.map(l => replace(indent, l))
.join('\n')
}

function replace (prefix, line) {
return line.slice(0, prefix.length) === prefix ? line.slice(prefix.length) : line
}

0 comments on commit 170a913

Please sign in to comment.