feature/fix-deployment-script
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | #!/usr/bin/env node |
| 2 | |
| 3 | import { spawnSync } from "child_process"; |
| 4 | |
| 5 | /** |
| 6 | * Returns the executable path which is located inside `node_modules` |
| 7 | * The naming convention is cli-${os}-${arch} |
| 8 | * If the platform is `win32` or `cygwin`, executable will include a `.exe` extension. |
| 9 | * @see https://nodejs.org/api/os.html#osarch |
| 10 | * @see https://nodejs.org/api/os.html#osplatform |
| 11 | * @example "x/xx/node_modules/cli-darwin-arm64" |
| 12 | */ |
| 13 | function getExePath() { |
| 14 | const arch = process.arch; |
| 15 | let os = process.platform as string; |
| 16 | let extension = ""; |
| 17 | if (["win32", "cygwin"].includes(process.platform)) { |
| 18 | os = "windows"; |
| 19 | extension = ".exe"; |
| 20 | } |
| 21 | |
| 22 | try { |
| 23 | // Since the binary will be located inside `node_modules`, we can simply call `require.resolve` |
| 24 | return require.resolve(`@smbcloud/cli-${os}-${arch}/bin/smb${extension}`); |
| 25 | } catch (e) { |
| 26 | throw new Error( |
| 27 | `Couldn't find application binary inside node_modules for ${os}-${arch}` |
| 28 | ); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Runs the application with args using nodejs spawn |
| 34 | */ |
| 35 | function run() { |
| 36 | const args = process.argv.slice(2); |
| 37 | const processResult = spawnSync(getExePath(), args, { stdio: "inherit" }); |
| 38 | process.exit(processResult.status ?? 0); |
| 39 | } |
| 40 | |
| 41 | run(); |