intercept-shell

0.1.4 • Public • Published

intercept-shell

拦截交互式的shell,并作出响应

自动回答如Inquirer.jsinput confirm list问题

var InterceptShell = require('intercept-shell');
 
let interceptShell = new InterceptShell({
    // 确认问题的回答
    confirm: (obj, cb) => {
        cb('y')
        console.log('this one');
        // console.log('标题是', obj.title);
    },
    // 列表问题
    list: (obj, cb, index) => {
        cb(1);
    },
    // 输入问题
    input: (obj, cb, index)=>{
        cb('成宽');
    }
});
 
var childProcess = cp.spawn('node', ['question.js'], {
    cwd: __dirname
});
 
childProcess.stdout.pipe(process.stdout);
 
interceptShell.setProcess(childProcess); // 传入childProcess
 

Readme

Keywords

none

Package Sidebar

Install

npm i intercept-shell

Weekly Downloads

1

Version

0.1.4

License

ISC

Unpacked Size

5.7 kB

Total Files

6

Last publish

Collaborators

  • zzuhan