cn-font-split
Version:
划时代的字体切割工具,CJK与任何字符!支持 otf、ttf、woff2 字体多线程切割,完美地细颗粒度地进行包大小控制。A revolutionary font subetter that supports CJK and any characters! It enables multi-threaded subset of otf, ttf, and woff2 fonts, allowing for precise control over package size.
1 lines • 3.26 kB
Source Map (JSON)
{"version":3,"file":"init.mjs","names":[],"sources":["../src/init.ts"],"sourcesContent":["import { execFile, spawn } from 'child_process';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { dirname } from 'path';\n\n// @ts-ignore 获取当前模块的 URL\nconst __filename = fileURLToPath(import.meta.url);\n\n// 获取当前模块所在的目录\nconst __dirname = dirname(__filename);\n\nexport function runInitScript() {\n const isWindows = process.platform === 'win32';\n\n // 获取除程序名和当前脚本外的所有命令行参数\n const args = process.argv.slice(2);\n\n if (isWindows) {\n // Windows平台下运行Powershell脚本\n const scriptPath = path.resolve(__dirname, './init.ps1');\n const powershellArgs = [\n '-ExecutionPolicy',\n 'Bypass',\n '-File',\n scriptPath,\n ...args,\n ];\n return new Promise((resolve, reject) => {\n execFile(\n 'powershell.exe',\n powershellArgs,\n (error, stdout, stderr) => {\n if (error) {\n console.error(\n `Error executing PowerShell script: ${error.message}`,\n );\n reject(error);\n return;\n }\n resolve(null);\n console.log(`PowerShell script output: ${stdout}`);\n },\n );\n });\n } else {\n // 非Windows平台(如Linux或macOS)下运行shell脚本\n const scriptPath = path.resolve(__dirname, './init.sh');\n const child = spawn('bash', [scriptPath, ...args], {\n stdio: 'inherit',\n });\n return new Promise((resolve, reject) => {\n child\n .on('close', (code) => {\n if (code !== 0) {\n reject();\n console.error(`Shell script exited with code ${code}`);\n } else {\n resolve(null);\n console.log('Shell script executed successfully.');\n }\n })\n .on('error', (err) => {\n reject(err);\n console.error('Failed to start shell script:', err);\n });\n });\n }\n}\n"],"mappings":";;;;AASA,IAAM,IAAY,EAHC,EAAc,OAAO,KAAK,GAGnB,CAAU;AAEpC,SAAgB,IAAgB;CAC5B,IAAM,IAAY,QAAQ,aAAa,SAGjC,IAAO,QAAQ,KAAK,MAAM,CAAC;CAEjC,IAAI,GAAW;EAGX,IAAM,IAAiB;GACnB;GACA;GACA;GAJe,EAAK,QAAQ,GAAW,YAKvC;GACA,GAAG;EACP;EACA,OAAO,IAAI,SAAS,GAAS,MAAW;GACpC,EACI,kBACA,IACC,GAAO,GAAQ,MAAW;IACvB,IAAI,GAAO;KAIP,AAHA,QAAQ,MACJ,sCAAsC,EAAM,SAChD,GACA,EAAO,CAAK;KACZ;IACJ;IAEA,AADA,EAAQ,IAAI,GACZ,QAAQ,IAAI,6BAA6B,GAAQ;GACrD,CACJ;EACJ,CAAC;CACL,OAAO;EAGH,IAAM,IAAQ,EAAM,QAAQ,CADT,EAAK,QAAQ,GAAW,WACd,GAAY,GAAG,CAAI,GAAG,EAC/C,OAAO,UACX,CAAC;EACD,OAAO,IAAI,SAAS,GAAS,MAAW;GACpC,EACK,GAAG,UAAU,MAAS;IACnB,AAAI,MAAS,KAIT,EAAQ,IAAI,GACZ,QAAQ,IAAI,qCAAqC,MAJjD,EAAO,GACP,QAAQ,MAAM,iCAAiC,GAAM;GAK7D,CAAC,EACA,GAAG,UAAU,MAAQ;IAElB,AADA,EAAO,CAAG,GACV,QAAQ,MAAM,iCAAiC,CAAG;GACtD,CAAC;EACT,CAAC;CACL;AACJ"}