UNPKG

hdw2

Version:

鸿蒙 hdc 调试工具

32 lines (24 loc) 785 B
import { chmodSync, existsSync } from 'node:fs'; import { debug, getHdc, getPlatformArch } from './util.js'; debug('hdc 权限修复脚本启动...'); const platformArch = getPlatformArch(); debug('当前平台:', platformArch); // 不支持平台 / Windows 直接跳过 if (!platformArch || platformArch === 'win-x86') { debug('当前平台无需修复权限'); process.exit(0); } const hdcPath = getHdc(); debug('hdc 路径:', hdcPath); if (!hdcPath || !existsSync(hdcPath)) { debug('未找到 hdc 文件,跳过权限修复'); process.exit(0); } try { chmodSync(hdcPath, 0o755); debug('hdc 权限修复成功'); } catch (err) { // postinstall 阶段:权限修复失败不应阻断安装 debug('hdc 权限修复失败,已忽略', err); } process.exit(0);