import * as fs from 'fs' ; import * as path from 'path' ; import * as child_process from 'child_process' ; let spawnSync = child_process . spawnSync ; export class TestUtils { param { string } task param { string [ ] } taskArgs param { Object } options static runCommand ( task , args , options ) { let child = spawnSync ( task , args , options ) ; return child . output ; } param { string } file returns { string [ ] } static getFileLines ( filePath ) { let contents = fs . readFileSync ( filePath ) . toString ( ) ; let lines = contents . split ( '\n' ) ; return lines ; } param { string } check param { string [ ] } file returns { boolean } static checkContent ( content , fileLines ) { for ( let pos = 0 ; pos < fileLines . length ; pos ++ ) { let line = fileLines [ pos ] ; if ( line . indexOf ( content ) >= 0 ) { return true ; } } return false ; } static checkContents ( lines , findLines ) { let found = true ; findLines . forEach ( line => { found = found && TestUtils . checkContent ( line , lines ) ; } ) ; if ( ! found ) { console . log ( lines . join ( '\n' ) ) ; } return found ; } }