0.1.4 • Published 6 years ago

intercept-shell v0.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

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