codexLocator.test.ts 1.1 KB

1234567891011121314151617181920212223242526
  1. import { describe, expect, it } from 'vitest';
  2. import { unpackedAsarPath } from './codexLocator';
  3. describe('unpackedAsarPath', () => {
  4. it('把 asar 内的可执行文件路径换成 unpacked 目录', () => {
  5. expect(
  6. unpackedAsarPath('C:\\app\\resources\\app.asar\\node_modules\\@openai\\codex-win32-x64\\bin\\codex.exe'),
  7. ).toBe(
  8. 'C:\\app\\resources\\app.asar.unpacked\\node_modules\\@openai\\codex-win32-x64\\bin\\codex.exe',
  9. );
  10. expect(unpackedAsarPath('/app/resources/app.asar/node_modules/x/bin/codex')).toBe(
  11. '/app/resources/app.asar.unpacked/node_modules/x/bin/codex',
  12. );
  13. });
  14. it('非路径边界的 app.asar 字样不误伤', () => {
  15. expect(unpackedAsarPath('/tmp/app.asarfoo/bar')).toBe('/tmp/app.asarfoo/bar');
  16. expect(unpackedAsarPath('/tmp/notapp.asar/bar')).toBe('/tmp/notapp.asar/bar');
  17. });
  18. it('未打包时原样返回', () => {
  19. expect(unpackedAsarPath('E:/workspace/zsjz-ai/ai-electron/node_modules/x/codex.exe')).toBe(
  20. 'E:/workspace/zsjz-ai/ai-electron/node_modules/x/codex.exe',
  21. );
  22. });
  23. });