var spawn = require('child_process').spawn;
const ls = spawn('adb', ['shell', '']);
var commands =["cd sdcard","cd libs","ls"]
ls.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
// if () {}
if (commands.length > 0) {
ls.stdin.write(commands[0] + '\n');
commands.shift()
}
});
ls.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
ls.on('close', (code) => {
console.log(`子进程退出码:${code}`);
});