Skip to content

Commit

Permalink
hide nodejs error when execFileSync fails
Browse files Browse the repository at this point in the history
  • Loading branch information
chanyeinthaw committed May 14, 2024
1 parent f6e38f6 commit 5c56eaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 14 additions & 10 deletions node/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env node

const path = require('path');
const { execFileSync } = require('child_process');
const path = require("path");
const { execFileSync } = require("child_process");

const GOARCH_MAP = {
'arm64': 'arm64',
'x64': 'amd64',
arm64: "arm64",
x64: "amd64",
};

const GOOS_MAP = {
'darwin': 'darwin',
'linux': 'linux',
'win32': 'windows'
darwin: "darwin",
linux: "linux",
win32: "windows",
};

if (!(process.arch in GOARCH_MAP)) {
Expand All @@ -28,7 +28,11 @@ const arch = GOARCH_MAP[process.arch];
const platform = GOOS_MAP[process.platform];
const binaryName = `ssme-${platform}-${arch}`;

const ssmePath = path.dirname(require.resolve('ssme'));
const binPath = path.resolve(ssmePath, '..' ,'bin', binaryName);
const ssmePath = path.dirname(require.resolve("ssme"));
const binPath = path.resolve(ssmePath, "..", "bin", binaryName);

execFileSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
try {
execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
} catch {
process.exit(1);
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@
"files": [
"bin"
]

}

0 comments on commit 5c56eaf

Please sign in to comment.