@alanwang-merit/meritdata-platform-skill-package 1.0.6 → 1.0.7
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 +2 -5
- package/scripts/postinstall.js +8 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alanwang-merit/meritdata-platform-skill-package",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
@@ -11,8 +11,5 @@
|
|
|
11
11
|
"skills",
|
|
12
12
|
"rules",
|
|
13
13
|
"scripts"
|
|
14
|
-
]
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"top-package": "^1.0.1"
|
|
17
|
-
}
|
|
14
|
+
]
|
|
18
15
|
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
// ✅ 修复:使用解构赋值引入 getTopPackagePath
|
|
4
|
-
const { getTopPackagePath } = require('top-package');
|
|
5
3
|
|
|
6
4
|
// 1. 获取当前 npm 包所在的目录 (node_modules/@alanwang-merit/meritdata-platform-skill-package)
|
|
7
5
|
const currentPackagePath = path.resolve(__dirname, '..');
|
|
8
6
|
|
|
9
|
-
// 2.
|
|
10
|
-
|
|
7
|
+
// 2. 【纯原生实现】精准定位项目根目录:向上回溯找到 node_modules 的父级
|
|
8
|
+
// 无论当前在哪一层级,只要路径中包含 node_modules,就截取它之前的部分作为项目根目录
|
|
9
|
+
const nodeModulesIndex = currentPackagePath.indexOf('node_modules');
|
|
10
|
+
if (nodeModulesIndex === -1) {
|
|
11
|
+
console.error('❌ [postinstall] Error: Cannot find node_modules in path.');
|
|
12
|
+
process.exit(1); // 找不到则直接退出,防止错误复制
|
|
13
|
+
}
|
|
14
|
+
const projectRoot = currentPackagePath.substring(0, nodeModulesIndex);
|
|
11
15
|
|
|
12
16
|
// 3. 定义需要复制的目录映射
|
|
13
17
|
const copyMappings = [
|