| 1234567891011121314151617181920212223242526 |
- import { describe, expect, it } from 'vitest';
- import { unpackedAsarPath } from './codexLocator';
- describe('unpackedAsarPath', () => {
- it('把 asar 内的可执行文件路径换成 unpacked 目录', () => {
- expect(
- unpackedAsarPath('C:\\app\\resources\\app.asar\\node_modules\\@openai\\codex-win32-x64\\bin\\codex.exe'),
- ).toBe(
- 'C:\\app\\resources\\app.asar.unpacked\\node_modules\\@openai\\codex-win32-x64\\bin\\codex.exe',
- );
- expect(unpackedAsarPath('/app/resources/app.asar/node_modules/x/bin/codex')).toBe(
- '/app/resources/app.asar.unpacked/node_modules/x/bin/codex',
- );
- });
- it('非路径边界的 app.asar 字样不误伤', () => {
- expect(unpackedAsarPath('/tmp/app.asarfoo/bar')).toBe('/tmp/app.asarfoo/bar');
- expect(unpackedAsarPath('/tmp/notapp.asar/bar')).toBe('/tmp/notapp.asar/bar');
- });
- it('未打包时原样返回', () => {
- expect(unpackedAsarPath('E:/workspace/zsjz-ai/ai-electron/node_modules/x/codex.exe')).toBe(
- 'E:/workspace/zsjz-ai/ai-electron/node_modules/x/codex.exe',
- );
- });
- });
|