-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathcheck-sentry.js
30 lines (26 loc) · 926 Bytes
/
check-sentry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const { execSync } = require('child_process')
const { existsSync } = require('fs')
const { join } = require('path')
const basePath = process.cwd()
function getJoinPath(relativePath) {
return join(basePath, relativePath)
}
const sentryCliBinPath = getJoinPath('./node_modules/.bin/sentry-cli')
const nodeModulesSentryInstallPath = getJoinPath('./node_modules/@sentry/cli/scripts/install.js')
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
const SLEEP_TIME = 10000
async function checkSentry() {
const stdio = ['ignore', 'inherit', 'ignore']
if (existsSync(sentryCliBinPath)) {
try {
execSync(`${sentryCliBinPath} -V`, { stdio })
} catch (error) {
if (existsSync(nodeModulesSentryInstallPath)) {
execSync(`node ${nodeModulesSentryInstallPath}`)
await sleep(SLEEP_TIME)
execSync(`${sentryCliBinPath} -V`, { stdio })
}
}
}
}
checkSentry()