license import { existsSync , readdirSync } from 'fs' ; import { join , resolve as resolvePath } from 'path' ; import { spawn } from 'child_process' ; import * as log from 'fancy-log' ; import { SCHEMATICS_SPEC_TSCONFIG , SOURCE_DIR } from '../config' ; export function getPackagesWithSchematicsSpecs ( ) { return readdirSync ( SOURCE_DIR ) . filter ( ( p ) => existsSync ( join ( SOURCE_DIR , p , SCHEMATICS_SPEC_TSCONFIG ) ) ) ; } export function schematicFilePaths ( basePath ) { return [ `${ basePath }/**/*.json` , `${ basePath }/**/files/**/*` , '!./**/dist/**/*' ] ; } export function tsCompile ( binary , flags ) { return new Promise ( ( resolve , reject ) => { const binaryPath = resolvePath ( `./node_modules/.bin/${ binary }` ) ; const childProcess = spawn ( binaryPath , flags , { shell : true } ) ; childProcess . stdout . on ( 'data' , ( data ) => log ( `${ data }` ) ) ; childProcess . stderr . on ( 'data' , ( data ) => log . error ( `${ data }` ) ) ; childProcess . on ( 'exit' , ( exitCode ) => { exitCode === 0 ? resolve ( ) : reject ( `${ binary } compilation failure` ) ; } ) ; } ) ; }