diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f6658f..f661407 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -80,3 +80,12 @@ jobs: - name: Smoke test run: | node dist/cli.js + + - name: Test with asset + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + cd test + node ../dist/cli.js -a asset.txt --no-bundle sample.cjs + expected=$(cat asset.txt) + actual=$(./dist-bin/sample-linux-x64) + [ "$actual" = "$expected" ] diff --git a/src/impl.ts b/src/impl.ts index 216981e..4bc9057 100644 --- a/src/impl.ts +++ b/src/impl.ts @@ -177,6 +177,14 @@ export default async function ( } } + if (flags.assets) { + seaConfig.assets = seaConfig.assets || {}; + for (const asset of flags.assets) { + const assetPath = path.resolve(asset); + seaConfig.assets[asset] = assetPath; + } + } + await fs.writeFile(seaConfigPath, JSON.stringify(seaConfig)); const targetNodeBinary = await getNodeBinary( flags.nodeVersion, diff --git a/test/asset.txt b/test/asset.txt new file mode 100644 index 0000000..cd08755 --- /dev/null +++ b/test/asset.txt @@ -0,0 +1 @@ +Hello world! diff --git a/test/sample.cjs b/test/sample.cjs new file mode 100644 index 0000000..12a3e85 --- /dev/null +++ b/test/sample.cjs @@ -0,0 +1,2 @@ +const sea = require('node:sea'); +console.log(new TextDecoder().decode(sea.getRawAsset('asset.txt')));