diff --git a/src/lib/parser/ParserRules.test.ts b/src/lib/parser/ParserRules.test.ts index bad0f726..4bb1bd6a 100644 --- a/src/lib/parser/ParserRules.test.ts +++ b/src/lib/parser/ParserRules.test.ts @@ -19,8 +19,9 @@ describe('ParserRules', () => { try { await ParserRules.Load('owner', 'id'); } catch (error) { - expect(error).toBeInstanceOf(TypeError); - expect(error.message).toContain('Cannot read properties of undefined'); + const typedError = error as TypeError; + expect(typedError).toBeInstanceOf(TypeError); + expect(typedError.message).toContain('Cannot read properties of undefined'); } }); -}); \ No newline at end of file +}); \ No newline at end of file diff --git a/src/lib/zip/fallback/unpack.ts b/src/lib/zip/fallback/unpack.ts index 95657577..33e8572a 100644 --- a/src/lib/zip/fallback/unpack.ts +++ b/src/lib/zip/fallback/unpack.ts @@ -1,4 +1,6 @@ import { spawn } from 'node:child_process'; +import { createWriteStream } from 'node:fs'; +import { join } from 'node:path'; import { listFiles } from './listFiles'; import { File } from './types'; @@ -7,15 +9,19 @@ const TAR_PATH = '/usr/bin/bsdtar'; export function unpack(filePath: string, workspace: string): Promise { return new Promise((resolve, reject) => { + const stdoutLogPath = join(workspace, 'tar_stdout.log'); + const stderrLogPath = join(workspace, 'tar_stderr.log'); + + const stdoutStream = createWriteStream(stdoutLogPath, { flags: 'a' }); + const stderrStream = createWriteStream(stderrLogPath, { flags: 'a' }); + const decompressProcess = spawn(TAR_PATH, ['xvf', filePath], { cwd: workspace, }); - decompressProcess.stdout.on('data', (data) => { - console.log(`tar output: ${data}`); - }); - decompressProcess.stderr.on('data', (data) => { - console.error(`tar error: ${data}`); - }); + + decompressProcess.stdout.pipe(stdoutStream); + decompressProcess.stderr.pipe(stderrStream); + decompressProcess.on('close', () => { // We are not reading the status code because we support partial extraction listFiles(workspace).then(resolve).catch(reject);