32 lines
774 B
JavaScript
32 lines
774 B
JavaScript
import cmd from '../src/cmd'
|
|
import tc from '@uci/try-catch'
|
|
|
|
;
|
|
(async () => {
|
|
|
|
|
|
// let cmdStr = `nmcli -w 10 device wifi connect ${ap.ssid} password ${ap.password} iface ${ap.iface}`
|
|
|
|
|
|
let cmdStr = 'ls'
|
|
console.log('command=> ',cmdStr)
|
|
let ret = await tc(cmd)(cmdStr)
|
|
if (ret.err) throw new Error('badness')
|
|
console.log(ret.res)
|
|
|
|
cmdStr = 'lx'
|
|
console.log('command=> ',cmdStr)
|
|
ret = await cmd(cmdStr)
|
|
console.log(ret.res)
|
|
|
|
// Alternate try catch and then throw some other error or whatever
|
|
// cmdStr = 'lx'
|
|
// console.log('command=> ',cmdStr)
|
|
// ret = await tc(cmd)(cmdStr)
|
|
// if (ret.err) throw new Error('caught and threw the error')
|
|
// console.log(ret.res)
|
|
|
|
})().catch(err => {
|
|
console.error('======Caught Error!==========\n',err)
|
|
})
|