mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-07-10 02:30:15 +00:00
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import * as tar from 'tar'
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
|
|
describe('desktop runtime archive extraction', () => {
|
|
let tempRoot: string | null = null
|
|
|
|
afterEach(() => {
|
|
if (tempRoot) rmSync(tempRoot, { recursive: true, force: true })
|
|
tempRoot = null
|
|
})
|
|
|
|
it('extracts gzip tar archives through the Node tar library', async () => {
|
|
tempRoot = mkdtempSync(join(tmpdir(), 'hermes-runtime-extract-'))
|
|
const source = join(tempRoot, 'source')
|
|
const target = join(tempRoot, 'target')
|
|
const archive = join(tempRoot, 'runtime.tar.gz.download')
|
|
mkdirSync(join(source, 'python', 'Scripts'), { recursive: true })
|
|
writeFileSync(join(source, 'python', 'Scripts', 'hermes.exe'), 'launcher', 'utf-8')
|
|
|
|
await tar.c({
|
|
file: archive,
|
|
cwd: source,
|
|
gzip: true,
|
|
}, ['python'])
|
|
mkdirSync(target)
|
|
|
|
const { extractTarGzipArchive } = await import('../../packages/desktop/src/main/runtime-archive')
|
|
await extractTarGzipArchive(archive, target)
|
|
|
|
expect(readFileSync(join(target, 'python', 'Scripts', 'hermes.exe'), 'utf-8')).toBe('launcher')
|
|
})
|
|
})
|