From 3b27cea2f24b1a6b6c0c1efeba4e6b6b977a2258 Mon Sep 17 00:00:00 2001 From: Bobby Galli Date: Wed, 20 Mar 2024 12:18:24 -0400 Subject: [PATCH] fix: make node-dump-syms optional --- bin/index.ts | 18 +++++++++++------- package-lock.json | 16 ++++++++++++++++ package.json | 6 +++++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/bin/index.ts b/bin/index.ts index 31f54e9..83ed820 100644 --- a/bin/index.ts +++ b/bin/index.ts @@ -3,7 +3,6 @@ import { ApiClient, BugSplatApiClient, OAuthClientCredentialsClient, VersionsApi import commandLineArgs, { CommandLineOptions } from 'command-line-args'; import commandLineUsage from 'command-line-usage'; import { glob } from 'glob'; -import { dumpSyms as nodeDumpSyms } from 'node-dump-syms'; import { existsSync } from 'node:fs'; import { mkdir, readFile, stat } from 'node:fs/promises'; import { basename, join } from 'node:path'; @@ -109,12 +108,17 @@ import { CommandLineDefinition, argDefinitions, usageDefinitions } from './comma console.log(`Found files:\n ${symbolFilePaths.join('\n')}`); if (dumpSyms) { - symbolFilePaths = symbolFilePaths.map(file => { - console.log(`Dumping syms for ${file}...`); - const symFile = join(tmpDir, `${basename(file)}.sym`); - nodeDumpSyms(file, symFile); - return symFile; - }); + try { + const nodeDumpSyms = (await import('node-dump-syms')).dumpSyms; + symbolFilePaths = symbolFilePaths.map(file => { + console.log(`Dumping syms for ${file}...`); + const symFile = join(tmpDir, `${basename(file)}.sym`); + nodeDumpSyms(file, symFile); + return symFile; + }); + } catch (error) { + console.log('node-dump-syms not found, skipping sym dumping...'); + } } await uploadSymbolFiles(bugsplat, database, application, version, directory, symbolFilePaths); diff --git a/package-lock.json b/package-lock.json index 52c6cc8..bab7065 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,9 @@ "rimraf": "^5.0.0", "ts-node": "^10.9.2", "typescript": "^5.3.3" + }, + "optionalDependencies": { + "node-dump-syms": "^3.0.6" } }, "node_modules/@75lb/deep-merge": { @@ -1997,6 +2000,13 @@ "node": ">=10" } }, + "node_modules/node-dump-syms": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/node-dump-syms/-/node-dump-syms-3.0.6.tgz", + "integrity": "sha512-zdxWP7niMjGrPbNPpOQK9ENECa1z9E3K8y3YUuyXc04pgtCVYRDsyJz3EnR6AehxGORVGcpH/eYaUbn7OUWCHQ==", + "hasInstallScript": true, + "optional": true + }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -4812,6 +4822,12 @@ "semver": "^7.3.5" } }, + "node-dump-syms": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/node-dump-syms/-/node-dump-syms-3.0.6.tgz", + "integrity": "sha512-zdxWP7niMjGrPbNPpOQK9ENECa1z9E3K8y3YUuyXc04pgtCVYRDsyJz3EnR6AehxGORVGcpH/eYaUbn7OUWCHQ==", + "optional": true + }, "node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", diff --git a/package.json b/package.json index 181662c..c19af10 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "outputPath": "./pkg", "compress": "GZip", "assets": [ - "package.json" + "package.json", + "node_modules/node-dump-syms/dist/native/index.addon" ] }, "devDependencies": { @@ -91,5 +92,8 @@ "promise-retry": "^2.0.1", "rxjs": "^7.8.1", "workerpool": "^6.5.1" + }, + "optionalDependencies": { + "node-dump-syms": "^3.0.6" } }