Skip to content

Commit 4e77d33

Browse files
Use bundled node binary in ./bin scripts
1 parent 17e2ead commit 4e77d33

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

bin/studio-cli.bat

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ set ORIGINAL_CP=%ORIGINAL_CP: =%
88
rem Set code page to UTF-8
99
chcp 65001 >nul
1010

11-
set ELECTRON_EXECUTABLE=%~dp0..\..\Studio.exe
11+
set BUNDLED_NODE_EXECUTABLE=%~dp0node.exe
1212
set CLI_SCRIPT=%~dp0..\cli\main.js
1313

1414
rem Prevent node from printing warnings about NODE_OPTIONS being ignored
1515
set NODE_OPTIONS=
1616

17-
if exist "%ELECTRON_EXECUTABLE%" (
18-
set ELECTRON_RUN_AS_NODE=1
19-
call "%ELECTRON_EXECUTABLE%" "%CLI_SCRIPT%" %*
17+
if exist "%BUNDLED_NODE_EXECUTABLE%" (
18+
call "%BUNDLED_NODE_EXECUTABLE%" "%CLI_SCRIPT%" %*
2019
) else (
21-
if not exist "%CLI_SCRIPT%" (
22-
set CLI_SCRIPT=%~dp0..\dist\cli\main.js
23-
)
24-
call node "%CLI_SCRIPT%" %*
20+
if not exist "%CLI_SCRIPT%" (
21+
set CLI_SCRIPT=%~dp0..\dist\cli\main.js
22+
)
23+
call node "%CLI_SCRIPT%" %*
2524
)
2625

2726
rem Restore original code page

bin/studio-cli.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#!/bin/sh
22

3-
# The default assumption is that this script lives in `/Applications/Studio.app/Contents/Resources/bin/studio-cli.sh`
4-
CONTENTS_DIR=$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")
5-
ELECTRON_EXECUTABLE="$CONTENTS_DIR/MacOS/Studio"
3+
# The assumption is that this script lives in `/Applications/Studio.app/Contents/Resources/bin/studio-cli.sh`
4+
BIN_DIR=$(dirname "$(realpath "$0")")
5+
BUNDLED_NODE_EXECUTABLE="$BIN_DIR/node"
6+
CONTENTS_DIR=$(dirname "$(dirname "$BIN_DIR")")
67
CLI_SCRIPT="$CONTENTS_DIR/Resources/cli/main.js"
78

8-
if [ -x "$ELECTRON_EXECUTABLE" ]; then
9+
if [ -x "$BUNDLED_NODE_EXECUTABLE" ]; then
910
# Prevent node from printing warnings about NODE_OPTIONS being ignored
1011
unset NODE_OPTIONS
11-
ELECTRON_RUN_AS_NODE=1 exec "$ELECTRON_EXECUTABLE" "$CLI_SCRIPT" "$@"
12+
exec "$BUNDLED_NODE_EXECUTABLE" "$CLI_SCRIPT" "$@"
1213
else
1314
# If the default script path is not found, assume that this script lives in the development directory
1415
# and look for the CLI JS bundle in the `./dist` directory
1516
if ! [ -f "$CLI_SCRIPT" ]; then
16-
SCRIPT_DIR=$(dirname $(dirname "$(realpath "$0")"))
17+
SCRIPT_DIR=$(dirname "$(dirname "$(realpath "$0")")")
1718
CLI_SCRIPT="$SCRIPT_DIR/dist/cli/main.js"
1819
fi
1920

0 commit comments

Comments
 (0)