@icyfenix-dmla/cli 2026.4.19-920 → 2026.4.19-935

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icyfenix-dmla/cli",
3
- "version": "2026.4.19-920",
3
+ "version": "2026.4.19-935",
4
4
  "description": "DMLA 沙箱服务命令行工具",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -4,6 +4,8 @@
4
4
  */
5
5
  import express from 'express'
6
6
  import cors from 'cors'
7
+ import { fileURLToPath } from 'url'
8
+ import { resolve } from 'path'
7
9
  import sandboxRouter from './routes/sandbox.js'
8
10
 
9
11
  export const app = express()
@@ -30,8 +32,12 @@ app.use((err, req, res, next) => {
30
32
  })
31
33
  })
32
34
 
33
- // 仅在直接运行时启动服务器(测试时不启动)
34
- if (import.meta.url === `file://${process.argv[1]}`) {
35
+ // 仅在直接运行时启动服务器(被 import 时不启动)
36
+ // 使用路径比较,兼容 Windows Unix 系统
37
+ const __filename = fileURLToPath(import.meta.url)
38
+ const entryPoint = resolve(process.argv[1] || '')
39
+
40
+ if (__filename === entryPoint) {
35
41
  app.listen(PORT, () => {
36
42
  console.log(`🚀 DMLA 本地服务已启动`)
37
43
  console.log(` API: http://localhost:${PORT}`)