Skip to content

Commit 1b44f81

Browse files
authored
feat: Implemenent --asset flag handling (#3)
1 parent cac105b commit 1b44f81

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,12 @@ jobs:
8080
- name: Smoke test
8181
run: |
8282
node dist/cli.js
83+
84+
- name: Test with asset
85+
if: ${{ matrix.os == 'ubuntu-latest' }}
86+
run: |
87+
cd test
88+
node ../dist/cli.js -a asset.txt --no-bundle sample.cjs
89+
expected=$(cat asset.txt)
90+
actual=$(./dist-bin/sample-linux-x64)
91+
[ "$actual" = "$expected" ]

src/impl.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ export default async function (
177177
}
178178
}
179179

180+
if (flags.assets) {
181+
seaConfig.assets = seaConfig.assets || {};
182+
for (const asset of flags.assets) {
183+
const assetPath = path.resolve(asset);
184+
seaConfig.assets[asset] = assetPath;
185+
}
186+
}
187+
180188
await fs.writeFile(seaConfigPath, JSON.stringify(seaConfig));
181189
const targetNodeBinary = await getNodeBinary(
182190
flags.nodeVersion,

test/asset.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world!

test/sample.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const sea = require('node:sea');
2+
console.log(new TextDecoder().decode(sea.getRawAsset('asset.txt')));

0 commit comments

Comments
 (0)