-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck-sentry.js
More file actions
34 lines (30 loc) · 1.15 KB
/
Copy pathcheck-sentry.js
File metadata and controls
34 lines (30 loc) · 1.15 KB
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
31
32
33
34
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']
console.log('sentryCliBinPath', existsSync(sentryCliBinPath))
if (existsSync(sentryCliBinPath)) {
try {
console.log('sentryCliBinPath -V', `${sentryCliBinPath} -V`)
execSync(`${sentryCliBinPath} -V`, { stdio })
} catch (error) {
console.log('nodeModulesSentryInstallPath', existsSync(nodeModulesSentryInstallPath))
if (existsSync(nodeModulesSentryInstallPath)) {
execSync(`node ${nodeModulesSentryInstallPath}`)
await sleep(SLEEP_TIME)
console.log('睡眠')
execSync(`${sentryCliBinPath} -V`, { stdio })
}
}
}
}
checkSentry()