import execa from 'execa' ; import path from 'path' ; const stripAnsi = require ( 'strip-ansi' ) ; const FIXTURES_DIR = path . join ( __dirname , '../fixtures/' ) ; function normalizeOutput ( value ) { const ansiRemoved = stripAnsi ( value ) ; return ( ansiRemoved . replace ( new RegExp ( `^${ FIXTURES_DIR . replace ( /\\/g , '\\\\' ) }(.*?)$` , 'gm' ) , ( _ , c1 ) => `__ROOT__/${ c1 . replace ( /\\/g , '/' ) }` ) . replace ( 'mmax-len' , 'max-len' ) ) ; } export async function runLint ( directory ) { try { const subprocess = execa ( 'npx' , [ 'ng' , 'lint' ] , { cwd : path . join ( FIXTURES_DIR , directory ) , } ) ; subprocess . stdout ! . pipe ( process . stdout ) ; subprocess . stderr ! . pipe ( process . stderr ) ; const { stdout } = await subprocess ; return normalizeOutput ( stdout ) ; } catch ( error ) { return normalizeOutput ( error . stdout || error ) ; } }