Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Closes #252, Replace readline REPL with repl REPL, which does autocom…

…plete for us.
  • Loading branch information...
commit bb901853db32f5b7dd283a4d82794f2dc80a057c 1 parent 7dbdced
@larzconwell larzconwell authored
Showing with 37 additions and 45 deletions.
  1. +37 −45 templates/Jakefile
View
82 templates/Jakefile
@@ -112,63 +112,55 @@ namespace('console', function () {
, t = jake.Task['env:init'];
t.addListener('complete', function () {
- var readline = require('readline')
- , rl = readline.createInterface({
- input: process.stdin
- , output: process.stdout
- });
-
- rl.setPrompt('>>> ');
- rl.prompt();
+ var repl = require('repl')
+ , rl;
- rl.addListener('line', function (line) {
- try {
- console.log(global.eval(line));
- }
- catch (e) {
- console.log(e.stack);
- }
- rl.prompt();
+ rl = repl.start({
+ prompt: '>>> '
+ , input: process.stdin
+ , output: process.stdout
});
- rl.addListener('close', function () {
- console.log('Exiting ...');
+ rl.on('close', function () {
+ console.log('Exiting...');
return complete();
- });
- });
+ })
- global.capture = function (err, data) {
- return global.results = {
- err: err
- , data: data
+ rl.context.capture = function (err, data) {
+ return rl.context.results = {
+ err: err
+ , data: data
+ };
};
- }
- global.echo = function (err, data) {
- capture(err, data);
- if (err) {
- console.log('Error: ', err);
- }
- if (data) {
- if (data.length) {
- for (var i in data) {
- if (data[i] && data[i].toData) {
- console.log(data[i].toData());
+ rl.context.echo = function (err, data) {
+ rl.context.capture(err, data);
+ if (err) {
+ console.log('Error: ', err);
+ }
+
+ if (data) {
+ if (data.length) {
+ for (var i in data) {
+ if (data[i] && data[i].toData) {
+ console.log(data[i].toData());
+ } else {
+ console.log(data[i]);
+ }
+ }
+ }
+ else {
+ if (data && data.toData) {
+ console.log(data.toData());
} else {
- console.log(data[i]);
+ console.log(data);
}
}
} else {
- if (data && data.toData) {
- console.log(data.toData());
- } else {
- console.log(data);
- }
+ console.log('No data');
}
- } else {
- console.log('No data');
- }
- }
+ };
+ });
t.invoke(env);
});
Please sign in to comment.
Something went wrong with that request. Please try again.