@heap-snapshot/cli 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/heap-snapshot +44 -0
  2. package/package.json +19 -0
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const path = require("path");
5
+
6
+ const PLATFORMS = {
7
+ "darwin-arm64": "@heap-snapshot/darwin-arm64",
8
+ "linux-x64": "@heap-snapshot/linux-x64",
9
+ "linux-arm64": "@heap-snapshot/linux-arm64",
10
+ "win32-x64": "@heap-snapshot/win32-x64",
11
+ "win32-arm64": "@heap-snapshot/win32-arm64",
12
+ };
13
+
14
+ const key = `${process.platform}-${process.arch}`;
15
+ const pkg = PLATFORMS[key];
16
+
17
+ if (!pkg) {
18
+ console.error(
19
+ `Error: heap-snapshot does not have a prebuilt binary for ${key}.`
20
+ );
21
+ process.exit(1);
22
+ }
23
+
24
+ let binPath;
25
+ try {
26
+ const exe = process.platform === "win32" ? "heap-snapshot.exe" : "heap-snapshot";
27
+ binPath = path.join(path.dirname(require.resolve(`${pkg}/package.json`)), exe);
28
+ } catch (e) {
29
+ console.error(
30
+ `Error: Could not find the ${pkg} package.\n` +
31
+ "Make sure it was installed — optional dependencies may have been skipped.\n" +
32
+ "Try reinstalling with: npm install @heap-snapshot/cli"
33
+ );
34
+ process.exit(1);
35
+ }
36
+
37
+ try {
38
+ execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
39
+ } catch (e) {
40
+ if (e.status !== undefined) {
41
+ process.exit(e.status);
42
+ }
43
+ throw e;
44
+ }
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@heap-snapshot/cli",
3
+ "version": "0.0.3",
4
+ "description": "V8 heap snapshot analyzer",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "heap-snapshot": "bin/heap-snapshot"
8
+ },
9
+ "optionalDependencies": {
10
+ "@heap-snapshot/darwin-arm64": "0.0.3",
11
+ "@heap-snapshot/linux-x64": "0.0.3",
12
+ "@heap-snapshot/linux-arm64": "0.0.3",
13
+ "@heap-snapshot/win32-x64": "0.0.3",
14
+ "@heap-snapshot/win32-arm64": "0.0.3"
15
+ },
16
+ "engines": {
17
+ "node": ">=16"
18
+ }
19
+ }