@apdesign/code-style-react 1.2.0 → 1.2.2

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": "@apdesign/code-style-react",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "scripts": {},
5
5
  "bin": {
6
6
  "apdesign-code-style": "cli.js"
@@ -37,7 +37,8 @@ async function runEslint(targetPathArg) {
37
37
  // targetPath 是第一个不是 --branch 的参数
38
38
  let targetPath = process.cwd();
39
39
  for (let i = 0; i < args.length; i++) {
40
- if (i === branchIndex || i === branchIndex + 1) continue;
40
+ // 仅当确实存在 --branch 参数时才跳过它和它的值
41
+ if (branchIndex !== -1 && (i === branchIndex || i === branchIndex + 1)) continue;
41
42
  targetPath = args[i] || targetPath;
42
43
  break;
43
44
  }
@@ -76,8 +77,11 @@ async function runEslint(targetPathArg) {
76
77
 
77
78
  let targetBranch = 'master';
78
79
  if (targetPath !== process.cwd()) {
79
- const lastDir = path.basename(rootDir);
80
- targetBranch = `master-${lastDir.split('-').pop()}`;
80
+ const pkgName = path.basename(targetPath); // 直接取传入的目录名
81
+ if (pkgName && pkgName.includes('-')) {
82
+ const suffix = pkgName.split('-').pop();
83
+ targetBranch = `master-${suffix}`;
84
+ }
81
85
  }
82
86
 
83
87
  // 获取当前分支
@@ -143,7 +147,8 @@ async function runEslint(targetPathArg) {
143
147
  const srcPath = path.join(rootDir, 'src');
144
148
  const eslintTarget = fs.existsSync(srcPath) ? srcPath : '.';
145
149
  if (!fs.existsSync(srcPath)) {
146
- console.warn(`🔍 src 文件夹不存在,改为检查当前目录: ${eslintTarget}`);
150
+ console.error(`❌ 当前目录下不存在 src 文件夹`);
151
+ process.exit(1);
147
152
  } else {
148
153
  console.log(`🔍 检查目录: ${eslintTarget}`);
149
154
  }