Reputation: 812
I have add the following vorpal command.
vorpal
.command('connect [username] [password]')
.description('Connect to server.')
.action(function (args, callback) {
setTimeout(function () {
// deleting options key from args
delete args.options;
var context = domain.create();
// error handling in domain
context.on('error', errorHandler);
// running the connect in domain
context.run(function() {
console.log("Arguments : ", args);
});
}, 0);
});
vorpal.delimiter('hdb$').show();
Following is the stack trace as it is generated in side the vorpal library only.
Vorpal Prompt error: TypeError: Cannot read property 'setRawMode' of null
at ReadStream.setRawMode (tty.js:67:15)
at Interface._setRawMode (readline.js:177:23)
at new Interface (readline.js:137:10)
at Object.exports.createInterface (readline.js:39:10)
at Object.Interface.createInterface (/home/users/my-cli/node_modules/vorpal/node_modules/inquirer/node_modules/readline2/index.js:34:21)
at module.exports (/home/users/my-cli/node_modules/vorpal/node_modules/inquirer/lib/ui/baseUI.js:14:30)
at new module.exports (/home/users/my-cli/node_modules/vorpal/node_modules/inquirer/lib/ui/prompt.js:15:8)
at Object.promptModule as prompt
at Object.ui.prompt (/home/users/my-cli/node_modules/vorpal/lib/ui.js:171:25)
at EventEmitter.vorpal._prompt (/home/users/my-cli/node_modules/vorpal/lib/vorpal.js:528:15)
at EventEmitter. (/home/users/my-cli/node_modules/vorpal/lib/vorpal.js:542:12)
at callback (/home/users/my-cli/node_modules/vorpal/lib/vorpal.js:705:22)
at /home/users/my-cli/node_modules/vorpal/lib/vorpal.js:824:7
at EventEmitter._commandSetCallback (/home/users/my-cli/node_modules/vorpal/lib/session.js:455:5)
at EventEmitter.session.completeCommand (/home/users/my-cli/node_modules/vorpal/lib/session.js:519:12)
at onCompletion (/home/users/my-cli/node_modules/vorpal/lib/session.js:465:10)
Please let me know if I am doing something wrong in this.
Upvotes: 1
Views: 544
Reputation: 20750
I think this may simply be because you aren't running the callback after the command completes:
var vorpal = require('vorpal')();
vorpal
.command('connect [username] [password]')
.description('Connect to server.')
.action(function (args, callback) {
setTimeout(function(){
// ... your logic
callback();
}, 0)
});
vorpal.delimiter('hdb$').show();
The above works - start with the above logic, and then start adding in your logic. If it breaks again even with the callback, back track on a process of elimination to find what part of your logic is causing the problem.
Upvotes: 1