const util = require ( 'util' ) ; const execAsPromise = util . promisify ( require ( 'child_process' ) . exec ) ; param { string } cmd param { any } options param { string | number } defaultValue param { Function } toType returns { string | number } export async function exec ( cmd , options , defaultValue , toType = String ) { const { stdout } = await execAsPromise ( cmd , options ) ; return toType ( stdout . trim ( ) ) || defaultValue ; }