Skip to content

Commit

Permalink
fix: handling of multiple targets
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Oct 22, 2024
1 parent 0d0c124 commit 8eeade7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/sea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ async function downloadFile(url: string, filePath: string): Promise<void> {
}

async function extract(os: string, archivePath: string): Promise<string> {
const nodeDir = basename(archivePath, os === 'win32' ? '.zip' : '.tar.gz');
const nodeDir = basename(archivePath, os === 'win' ? '.zip' : '.tar.gz');
const archiveDir = dirname(archivePath);
let nodePath = '';

if (os === 'win32') {
if (os === 'win') {
// use unzipper to extract the archive
const { files } = await unzipper.Open.file(archivePath);
const nodeBinPath = `${nodeDir}/node.exe`;
Expand Down Expand Up @@ -128,12 +128,11 @@ async function verifyChecksum(
}

const allowedArchs = ['x64', 'arm64', 'armv7l', 'ppc64', 's390x'];
const allowedOSs = ['darwin', 'linux', 'win32'];
const allowedOSs = ['darwin', 'linux', 'win'];

function getNodeOs(platform: string) {
const platformsMap: Record<string, string> = {
macos: 'darwin',
win: 'win32',
};

const validatedPlatform = platformsMap[platform] || platform;
Expand Down Expand Up @@ -215,7 +214,7 @@ async function getNodejsExecutable(
const os = getNodeOs(target.platform);
const arch = getNodeArch(target.arch);

const fileName = `node-${nodeVersion}-${os}-${arch}.${os === 'win32' ? 'zip' : 'tar.gz'}`;
const fileName = `node-${nodeVersion}-${os}-${arch}.${os === 'win' ? 'zip' : 'tar.gz'}`;
const url = `https://nodejs.org/dist/${nodeVersion}/${fileName}`;
const checksumUrl = `https://nodejs.org/dist/${nodeVersion}/SHASUMS256.txt`;
const downloadDir = join(homedir(), '.pkg-cache', 'sea');
Expand Down Expand Up @@ -309,7 +308,7 @@ export default async function sea(entryPoint: string, opts: SeaOptions) {

// copy the executable as the output executable
await copyFile(nodePath, outPath);

log.info('Injecting the blob...');
await exec(
`npx postject "${outPath}" NODE_SEA_BLOB "${blobPath}" --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2`,
Expand Down

0 comments on commit 8eeade7

Please sign in to comment.