interactive
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -50,2 +50,20 @@ var util = require('util'); | ||
var clearLine = function () { | ||
pos = 0; | ||
tmp = ""; | ||
display = ""; | ||
refreshLine(); | ||
}; | ||
var execute = function (code) { | ||
try { | ||
stdout.write('\n'); | ||
result = eval.apply(global, [code]); | ||
stdout.write('\u001b[37m' + util.inspect(result) + '\u001b[0m'); | ||
} catch (e) { | ||
stdout.write(e.toString() + e.stack); | ||
} | ||
stdout.write('\n'); | ||
}; | ||
var processKey = function( key ){ | ||
@@ -93,15 +111,11 @@ switch (key) { | ||
if(exists) { | ||
fs.readFile(path, {encoding:'utf8'}, function(err, data) { | ||
fs.readFile(path, { encoding: 'utf8' }, function(err, data) { | ||
if(err) { | ||
stdout.write("Couldn't load snippet"); | ||
stdout.write("\nCouldn't load snippet\n"); | ||
clearLine(); | ||
} else { | ||
command_memory.push(display); | ||
index = command_memory.length; | ||
stdout.write('\n'); | ||
result = eval.apply(global, [data]); | ||
stdout.write('\u001b[37m' + util.inspect(result) + '\u001b[0m\n'); | ||
pos = 0; | ||
tmp = ""; | ||
display = ""; | ||
refreshLine(); | ||
execute(data); | ||
clearLine(); | ||
} | ||
@@ -111,6 +125,3 @@ }); | ||
stdout.write("\nFile doesn't exist!\n"); | ||
pos = 0; | ||
tmp = ""; | ||
display = ""; | ||
refreshLine(); | ||
clearLine(); | ||
} | ||
@@ -123,8 +134,5 @@ }); | ||
if(saved.length === 0) { | ||
stdout.write('\n\u001b[37mundefined\u001b[0m'); | ||
stdout.write('\n\u001b[37mundefined\u001b[0m\n'); | ||
} | ||
pos = 0; | ||
tmp = ""; | ||
display = ""; | ||
refreshLine(); | ||
clearLine(); | ||
break; | ||
@@ -137,23 +145,12 @@ } | ||
if(indentation === 0) { | ||
try { | ||
stdout.write('\n'); | ||
result = eval.apply(global, [saved]); | ||
stdout.write('\u001b[37m' + util.inspect(result) + '\u001b[0m'); | ||
} catch (e) { | ||
stdout.write(e.toString() + e.stack); | ||
} finally { | ||
saved = ""; | ||
} | ||
index = command_memory.length; | ||
if(command_memory.length > 100) { | ||
command_memory.shift(); | ||
} | ||
execute(saved); | ||
saved = ""; | ||
} | ||
tmp = ""; | ||
display = ""; | ||
pos = 0; | ||
stdout.write('\n'); | ||
refreshLine(); | ||
while(command_memory.length > 100) { | ||
command_memory.shift(); | ||
} | ||
index = command_memory.length; | ||
clearLine(); | ||
break; | ||
@@ -160,0 +157,0 @@ /*---------------------------------------------/ |
{ | ||
"name": "interactive", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "Togglable interactive mode", | ||
@@ -5,0 +5,0 @@ "main": "interactive.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
11941
263