Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
T treasure
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 12
    • Issues 12
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FE
  • treasure
  • Issues
  • #39

Closed
Open
Created Aug 18, 2021 by JayChen@JayChenOwner

sentry-cli目录识别异常的问题解决方案

原因:缺失sentry-cli根据系统类型的二进制执行文件,未能正确的实行已经提供的安装脚本,脚本路径紊乱.
结果:导致sentry-cli重新从外网下载,而由于最近一段时间外网翻墙限制,导致sentry包无法正常install、安装

解决方法如下:install之后辅助完成下载

// package.json
"scripts": {
   "prepare": "husky install; node check-sentry.js",
}
// check-sentry.js
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();
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking