Skip to content
This repository was archived by the owner on Aug 14, 2020. It is now read-only.

Commit 13c14c3

Browse files
handle ci and --
1 parent cc2642c commit 13c14c3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ const fs = require('fs')
66
const SCOPE_DSN = 'SCOPE_DSN'
77

88
const 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

1616
const DEFAULT_COMMAND = 'npm test'
1717

1818
const NPM_INSTALL_COMMAND = 'npm install --save-dev @undefinedlabs/scope-agent'
1919
const 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

2323
async 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

Comments
 (0)