tput: debug info for {init,reset}_file. fix global var.

This commit is contained in:
Christopher Jeffrey 2015-02-21 13:52:39 -08:00
parent 77695f994a
commit 02ca94a8d9
1 changed files with 9 additions and 2 deletions

View File

@ -705,7 +705,8 @@ Tput.prototype.inject = function(info) {
// ~/ncurses/ncurses/tinfo/lib_tparm.c
// ~/ncurses/ncurses/tinfo/comp_scan.c
Tput.prototype._compile = function(info, key, str) {
var self = this;
var self = this
, v;
this._debug('Compiling %s: %s', key, JSON.stringify(str));
@ -729,8 +730,14 @@ Tput.prototype._compile = function(info, key, str) {
// ~/ncurses/progs/tset.c - set_init() - L992
if (key === 'init_file' || key === 'reset_file') {
try {
// NOTE: Should we consider this code and parse it instead?
str = fs.readFileSync(str, 'utf8');
if (this.debug) {
v = ('return "' + str + '";')
.replace(/\x1b/g, '\\x1b')
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n');
process.stdout.write(v + '\n');
}
return function() { return str; };
} catch (e) {
return noop;