crabatool 1.0.23 → 1.0.26
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/index.js +11 -0
- package/package.json +5 -2
- package/tool/checkjs.js +2 -2
package/index.js
CHANGED
|
@@ -28,6 +28,17 @@ module.exports.run = function(options) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function checkConfig() {
|
|
31
|
+
if (process.argv.length > 2) {
|
|
32
|
+
var arr = [...process.argv];
|
|
33
|
+
// 支持根据参数传入web地址,开发环境是地址1,构建环境是地址2,而配置是写死的,通过参数灵活指定
|
|
34
|
+
if (arr.includes('-webPath')) {
|
|
35
|
+
var index = arr.indexOf('-webPath');
|
|
36
|
+
var webPath = arr[index + 1];
|
|
37
|
+
if (!webPath) throw new Error('-webPath参数缺少参数值');
|
|
38
|
+
config.webPath = webPath;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
if (!config.webPath) {
|
|
32
43
|
throw new Error('请检查craba.js,必须告诉工具当前项目的前端路径地址,填绝对路径哦');
|
|
33
44
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crabatool",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "crabatool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "node index.js",
|
|
8
|
-
"test": "node ./test/test.js"
|
|
8
|
+
"test": "node ./test/test.js",
|
|
9
|
+
"run": "node ./test/test.js -run",
|
|
10
|
+
"checkjs": "node ./test/test.js -checkjs",
|
|
11
|
+
"webPath": "node ./test/test.js -checkjs -webPath F:、\newcrabadoc\\www"
|
|
9
12
|
},
|
|
10
13
|
"author": "wssf",
|
|
11
14
|
"dependencies": {
|
package/tool/checkjs.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports.start = function() {
|
|
|
30
30
|
var stats = fs.statSync(filePath);
|
|
31
31
|
if (stats.size / 1024 > fileSize) { // 大于300k的js视为大文件
|
|
32
32
|
if (!blackList.includes(path.basename(filePath))) {
|
|
33
|
-
bigList.push(
|
|
33
|
+
bigList.push(`${filePath} ${parseInt(stats.size / 1024)}kb`);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -88,7 +88,7 @@ module.exports.start = function() {
|
|
|
88
88
|
info.push(`# ${s}`);
|
|
89
89
|
|
|
90
90
|
var err = errRegList[index];
|
|
91
|
-
info.push("| 异常字符 |
|
|
91
|
+
info.push("| 异常字符 | 位置 |");
|
|
92
92
|
info.push("| ----- | ------ |");
|
|
93
93
|
err.list.forEach((item) => {
|
|
94
94
|
info.push(`| ${item.char} | ${item.index} |`);
|