import child_process = require ( "child_process" ) ; import SFPLogger from "../logger/SFPLogger" ; export default class ValidateTestCoveragePackageImpl { public constructor ( private target_org , private required_coverage , private package_version_id ) { } public async exec ( command ) { let output = child_process . execSync ( command , { encoding : "utf8" } ) ; let result = JSON . parse ( output ) ; if ( Number ( result . result . coverage ) < this . required_coverage ) throw new Error ( `Package Code Coverage is currently at ${ result . result . coverage }, which is less than the required coverage ${ this . required_coverage } ` ) ; SFPLogger . log ( `Package Code Coverage is currently at ${ result . result . coverage }` ) ; } public async buildExecCommand ( ) { let command = `sfdx sfpowerkit:package:version:codecoverage -v  ${ this . target_org } -i ${ this . package_version_id } --json` ; return command ; } }