@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 +1 -1
- package/src/server/index.js +8 -2
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -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
|
-
|
|
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}`)
|