summaryrefslogtreecommitdiff
path: root/src/main/compilationManager.ts
diff options
context:
space:
mode:
authorhaoyuren <13851610112@163.com>2026-07-30 09:00:55 +0800
committerhaoyuren <13851610112@163.com>2026-07-30 09:00:55 +0800
commit7297f7c339186f8af50f4f0ed3734e4ad4b47aed (patch)
tree9c5b02d50bf7ab5ac64b07ba436f9e2319a87208 /src/main/compilationManager.ts
parentc9cd5119077c69088eb8ba768ee1e1602baec751 (diff)
Cross-platform support: Windows build target and CI release workflow
- Normalize watcher paths to forward slashes (Windows events use backslashes; all sync maps are '/'-keyed), path.delimiter for PATH/TEXINPUTS, dirname() instead of '/'-substring splits, bridge log in os.tmpdir() - Platform-aware TeX search paths (TeX Live / MiKTeX on Windows), terminal shell default (COMSPEC/powershell), native window frame off macOS - electron-builder: NSIS target + win icon + GitHub publish provider - GitHub Actions workflow builds the Windows installer on tag push (node-pty needs MSVC — cannot cross-compile from macOS) and attaches it to the release Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'src/main/compilationManager.ts')
-rw-r--r--src/main/compilationManager.ts28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/main/compilationManager.ts b/src/main/compilationManager.ts
index 72c0c5e..2e27476 100644
--- a/src/main/compilationManager.ts
+++ b/src/main/compilationManager.ts
@@ -2,7 +2,7 @@
// Licensed under AGPL-3.0 - see LICENSE file
// Manages temp directory for Overleaf socket-mode compilation
-import { join, basename } from 'path'
+import { join, basename, dirname, delimiter } from 'path'
import { writeFile, mkdir, rm } from 'fs/promises'
import { existsSync } from 'fs'
import { spawn } from 'child_process'
@@ -42,7 +42,7 @@ export class CompilationManager {
await mkdir(this.tmpDir, { recursive: true })
for (const [relPath, content] of this.docContents) {
const fullPath = join(this.tmpDir, relPath)
- const dir = fullPath.substring(0, fullPath.lastIndexOf('/'))
+ const dir = dirname(fullPath)
await mkdir(dir, { recursive: true })
await writeFile(fullPath, content, 'utf-8')
}
@@ -53,7 +53,7 @@ export class CompilationManager {
if (this.fileRefCache.has(relativePath)) return
const fullPath = join(this.tmpDir, relativePath)
- const dir = fullPath.substring(0, fullPath.lastIndexOf('/'))
+ const dir = dirname(fullPath)
await mkdir(dir, { recursive: true })
return new Promise((resolve, reject) => {
@@ -99,17 +99,23 @@ export class CompilationManager {
): Promise<{ success: boolean; log: string; pdfPath: string }> {
await this.syncDocs()
- const texPaths = [
- '/Library/TeX/texbin',
- '/usr/local/texlive/2024/bin/universal-darwin',
- '/usr/texbin',
- '/opt/homebrew/bin'
- ]
- const envPath = texPaths.join(':') + ':' + (process.env.PATH || '')
+ const texPaths = process.platform === 'win32'
+ ? [
+ 'C:\\texlive\\2025\\bin\\windows',
+ 'C:\\texlive\\2024\\bin\\windows',
+ join(process.env.LOCALAPPDATA || '', 'Programs', 'MiKTeX', 'miktex', 'bin', 'x64')
+ ]
+ : [
+ '/Library/TeX/texbin',
+ '/usr/local/texlive/2024/bin/universal-darwin',
+ '/usr/texbin',
+ '/opt/homebrew/bin'
+ ]
+ const envPath = texPaths.join(delimiter) + delimiter + (process.env.PATH || '')
// Use // suffix for recursive search of ALL subdirectories in the project tree.
// This ensures .sty, .bst, .cls, images, etc. are always found regardless of nesting.
- const texInputs = `${this.tmpDir}//:`
+ const texInputs = `${this.tmpDir}//${delimiter}`
const texBase = basename(mainTexRelPath, '.tex')
const pdfPath = join(this.tmpDir, texBase + '.pdf')