mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-31 19:32:13 +08:00
refactor(scripts): optimizes file permission changes (#7520)
- Replaces shell-based execution of `chmod` with native Node.js filesystem API calls to improve performance - Switches to `execFileSync` in stream event handlers to avoid shell spawning overhead Signed-off-by: ❤是纱雾酱哟~ <49941141+Dragon1573@users.noreply.github.com> Co-authored-by: Tunglies <tunglies.dev@outlook.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { execSync } from 'child_process'
|
||||
import { execFileSync, execSync } from 'child_process'
|
||||
import { createHash } from 'crypto'
|
||||
import fs from 'fs'
|
||||
import fsp from 'fs/promises'
|
||||
@@ -409,7 +409,7 @@ async function resolveSidecar(binInfo) {
|
||||
throw new Error(`Expected binary not found in ${tempDir}`)
|
||||
await fsp.rename(path.join(tempDir, candidate), sidecarPath)
|
||||
}
|
||||
if (platform !== 'win32') execSync(`chmod 755 ${sidecarPath}`)
|
||||
if (platform !== 'win32') await fsp.chmod(sidecarPath, 0o755)
|
||||
log_success(`unzip finished: "${name}"`)
|
||||
} else if (zipFile.endsWith('.tgz')) {
|
||||
await extract({ cwd: tempDir, file: tempZip })
|
||||
@@ -425,7 +425,7 @@ async function resolveSidecar(binInfo) {
|
||||
if (!extracted) extracted = files[0]
|
||||
if (!extracted) throw new Error(`Expected file not found in ${tempDir}`)
|
||||
await fsp.rename(path.join(tempDir, extracted), sidecarPath)
|
||||
execSync(`chmod 755 ${sidecarPath}`)
|
||||
await fsp.chmod(sidecarPath, 0o755)
|
||||
log_success(`tgz processed: "${name}"`)
|
||||
} else {
|
||||
// .gz
|
||||
@@ -440,7 +440,8 @@ async function resolveSidecar(binInfo) {
|
||||
})
|
||||
.pipe(writeStream)
|
||||
.on('finish', () => {
|
||||
if (platform !== 'win32') execSync(`chmod 755 ${sidecarPath}`)
|
||||
if (platform !== 'win32')
|
||||
execFileSync('chmod', ['755', sidecarPath])
|
||||
resolve()
|
||||
})
|
||||
.on('error', (e) => {
|
||||
|
||||
Reference in New Issue
Block a user