Skip to content

Commit 5a21390

Browse files
committed
Win bat
1 parent c4c9955 commit 5a21390

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

stampers/win.bat

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@echo off
2+
setlocal
3+
4+
:: Check for required arguments
5+
if "%~3"=="" (
6+
echo Usage: %0 executable_name js_source_file output_folder
7+
exit /b 1
8+
)
9+
10+
:: Define variables from command line arguments
11+
set "EXE_NAME=%~1"
12+
set "JS_SOURCE_FILE=%~2"
13+
set "OUTPUT_FOLDER=%~3"
14+
15+
:: Ensure output folder exists
16+
if not exist "%OUTPUT_FOLDER%" mkdir "%OUTPUT_FOLDER%"
17+
18+
:: Create a JavaScript file
19+
echo console.log(`Hello, %%argv[2]!`); > "%JS_SOURCE_FILE%"
20+
21+
:: Create configuration file for SEA
22+
(
23+
echo {
24+
echo "main": "%JS_SOURCE_FILE%",
25+
echo "output": "sea-prep.blob",
26+
echo "disableExperimentalSEAWarning": true,
27+
echo "useCodeCache": true,
28+
echo "assets": {
29+
echo "index.html": "public/index.html",
30+
echo "favicon.ico": "public/favicon.ico",
31+
echo "top.html": "public/top.html",
32+
echo "style.css": "public/style.css",
33+
echo "injection.js": "public/injection.js",
34+
echo "redirector.html": "public/redirector.html"
35+
echo }
36+
echo }
37+
) > "%OUTPUT_FOLDER%\%SEA_CONFIG%"
38+
39+
:: Generate the blob to be injected
40+
node --experimental-sea-config "%OUTPUT_FOLDER%\%SEA_CONFIG%"
41+
42+
:: Copy the node executable and rename
43+
node -e "require('fs').copyFileSync(process.execPath, '%OUTPUT_FOLDER%\%EXE_NAME%')"
44+
45+
:: Optionally, remove signature from the binary (use signtool if necessary, or skip this step)
46+
:: signtool remove /s "%OUTPUT_FOLDER%\%EXE_NAME%"
47+
48+
:: Inject the blob into the copied binary
49+
npx postject "%OUTPUT_FOLDER%\%EXE_NAME%" NODE_SEA_BLOB sea-prep.blob ^
50+
--sentinel-fuse %NODE_SEA_FUSE%
51+
52+
:: Clean up
53+
del "%JS_SOURCE_FILE%"
54+
del "%OUTPUT_FOLDER%\%SEA_CONFIG%"
55+
del sea-prep.blob
56+
57+
echo Application built successfully.
58+
59+
:end
60+

0 commit comments

Comments
 (0)