crabatool 1.0.24 → 1.0.27

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 CHANGED
@@ -16,15 +16,6 @@ module.exports.run = function(options) {
16
16
  // 1. 服务端构建环境,自动化,根据命令行参数,直接调用脚手架功能
17
17
  if (process.argv.length > 2) {
18
18
  var arr = [...process.argv];
19
-
20
- // 支持根据参数传入web地址,开发环境是地址1,构建环境是地址2,而配置是写死的,通过参数灵活指定
21
- if (arr.includes('-webPath')) {
22
- var index = arr.indexOf('-webPath');
23
- var webPath = arr[index + 1];
24
- if (!webPath) throw new Error('-webPath参数缺少参数值');
25
- config.webPath = webPath;
26
- }
27
-
28
19
  if (arr.includes('-checkjs')) {
29
20
  return checkAllJs();
30
21
  } else if (arr.includes('-run')) {
@@ -36,7 +27,23 @@ module.exports.run = function(options) {
36
27
  waitInput();
37
28
  }
38
29
 
30
+ function bindConfigByArgv(key) {
31
+ if (process.argv.length < 3) return null;
32
+
33
+ var arr = [...process.argv];
34
+ if (arr.includes(key)) {
35
+ var index = arr.indexOf(key);
36
+ var value = arr[index + 1];
37
+ if (!value) throw new Error(key + '参数缺少参数值');
38
+ key = key.substr(1);
39
+ config[key] = value;
40
+ }
41
+ }
39
42
  function checkConfig() {
43
+ bindConfigByArgv('-webPath');
44
+ bindConfigByArgv('-modName');
45
+ bindConfigByArgv('-ignoreCheck');
46
+
40
47
  if (!config.webPath) {
41
48
  throw new Error('请检查craba.js,必须告诉工具当前项目的前端路径地址,填绝对路径哦');
42
49
  }
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "crabatool",
3
- "version": "1.0.24",
3
+ "version": "1.0.27",
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
@@ -8,7 +8,7 @@ var path = require('path');
8
8
  var axios = require('axios');
9
9
 
10
10
  module.exports.start = function() {
11
- var jsFiles = utils.getFiles({ source: config.webPath, exts: '.js' });
11
+ var jsFiles = utils.getFiles({ source: config.webPath, exts: '.js', ignores: config.ignoresCheck });
12
12
 
13
13
  var fileSize = 300;
14
14
  var errList = [];
@@ -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} |`);