@@ -6,19 +6,19 @@ const fs = require('fs')
66const SCOPE_DSN = 'SCOPE_DSN'
77
88const DEFAULT_ARGUMENTS = [
9- '--' ,
109 '--testRunner=@undefinedlabs/scope-agent/jest/testRunner' ,
1110 '--runner=@undefinedlabs/scope-agent/jest/runner' ,
1211 '--setupFilesAfterEnv=@undefinedlabs/scope-agent/jest/setupTests' ,
1312 '--runInBand' ,
13+ '--ci' ,
1414]
1515
1616const DEFAULT_COMMAND = 'npm test'
1717
1818const NPM_INSTALL_COMMAND = 'npm install --save-dev @undefinedlabs/scope-agent'
1919const YARN_INSTALL_COMMAND = 'yarn add --dev @undefinedlabs/scope-agent'
2020
21- const hasYarn = ( cwd = process . cwd ( ) ) => fs . existsSync ( path . resolve ( cwd , 'yarn.lock' ) )
21+ const isYarnRepo = ( cwd = process . cwd ( ) ) => fs . existsSync ( path . resolve ( cwd , 'yarn.lock' ) )
2222
2323async function run ( ) {
2424 try {
@@ -45,20 +45,20 @@ async function run() {
4545 console . log ( `DSN has been set.` )
4646 }
4747
48- const installCommand = hasYarn ( ) ? YARN_INSTALL_COMMAND : NPM_INSTALL_COMMAND
48+ const isYarn = isYarnRepo ( )
4949
50- await exec . exec ( installCommand , null , {
50+ await exec . exec ( isYarn ? YARN_INSTALL_COMMAND : NPM_INSTALL_COMMAND , null , {
5151 ignoreReturnCode : true ,
5252 } )
5353
54- return ExecScopeRun ( command , apiEndpoint , apiKey )
54+ return ExecScopeRun ( command , apiEndpoint , apiKey , isYarn )
5555 } catch ( error ) {
5656 core . setFailed ( error . message )
5757 }
5858}
5959
60- function ExecScopeRun ( command = DEFAULT_COMMAND , apiEndpoint , apiKey ) {
61- return exec . exec ( command , DEFAULT_ARGUMENTS , {
60+ function ExecScopeRun ( command = DEFAULT_COMMAND , apiEndpoint , apiKey , isYarn ) {
61+ return exec . exec ( command , isYarn ? DEFAULT_ARGUMENTS : [ '--' , ... DEFAULT_ARGUMENTS ] , {
6262 env : {
6363 ...process . env ,
6464 SCOPE_API_ENDPOINT : apiEndpoint ,
0 commit comments