From 303bd1c8be20dd0ef83c1e67d0d09a4c78ccc49b Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 24 Oct 2022 13:17:40 +0200 Subject: [PATCH] Add a means to detect if the CLI binary exists --- index.d.ts | 1 + src/index.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/index.d.ts b/index.d.ts index 4f1040e9..de4d7b83 100644 --- a/index.d.ts +++ b/index.d.ts @@ -130,6 +130,7 @@ declare namespace SentryCliPlugin { declare class SentryCliPlugin implements WebpackPluginInstance { options: SentryCliPlugin.SentryCliPluginOptions; constructor(options: SentryCliPlugin.SentryCliPluginOptions); + static cliBinaryExists(): string; apply(compiler: Compiler): void; } diff --git a/src/index.js b/src/index.js index abd0123c..b210ead4 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ const SentryCli = require('@sentry/cli'); +const fs = require('fs'); const path = require('path'); const util = require('util'); const { RawSource } = require('webpack-sources'); @@ -193,6 +194,10 @@ class SentryCliPlugin { return this.options.dryRun === true; } + static cliBinaryExists() { + return fs.existsSync(SentryCli.getPath()); + } + /** Creates a new Sentry CLI instance. */ getSentryCli() { const cli = new SentryCli(this.options.configFile, {