batch-exec-cli 1.3.1 → 1.3.4

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/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  高效批量命令执行工具,能够遍历目录内所有直接子目录并执行命令。
4
4
 
5
+ [![release status](https://github.com/chandq/batch-exec-cli/actions/workflows/release.yml/badge.svg)](https://github.com/chandq/batch-exec-cli/actions/workflows/release.yml)
6
+ [![batch-exec-cli](https://img.shields.io/github/package-json/v/chandq/batch-exec-cli?style=flat-square)](https://www.npmjs.com/package/batch-exec-cli)
7
+
5
8
  ## 功能特性
6
9
 
7
10
  - 🚀 高效遍历目标目录的所有直接子目录, 默认并行执行
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "batch-exec-cli",
3
- "version": "1.3.1",
3
+ "version": "1.3.4",
4
4
  "description": "Efficiently iterate through directories and execute commands with progress display and parallel execution",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -8,7 +8,8 @@
8
8
  "batch-exec": "src/cli.js"
9
9
  },
10
10
  "scripts": {
11
- "test": "echo 'Tests require Node.js >= 18.0.0 with --test support'",
11
+ "test": "node --test",
12
+ "test:coverage": "node --test --experimental-test-coverage --test-coverage-include='src/**' --test-coverage-exclude='test/**'",
12
13
  "lint": "eslint src/ test/"
13
14
  },
14
15
  "files": [
@@ -28,9 +29,9 @@
28
29
  ],
29
30
  "repository": {
30
31
  "type": "git",
31
- "url": "git+https://github.com/chandq/batch-exec.git"
32
+ "url": "git+https://github.com/chandq/batch-exec-cli.git"
32
33
  },
33
- "author": "",
34
+ "author": "chandq",
34
35
  "license": "MIT",
35
36
  "dependencies": {
36
37
  "minimist": "^1.2.8",
package/src/cli.js CHANGED
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { createRequire } from 'module';
3
4
  import path from 'path';
4
5
  import minimist from 'minimist';
5
6
  import { $ } from 'zx';
6
7
  import { batchExecute, parseIgnoreFile } from './index.js';
7
8
  import { cyan, yellow, green, red, gray, bold, dim, magenta, blue } from './utils/colors.js';
8
9
 
10
+ const require = createRequire(import.meta.url);
11
+ const { version } = require('../package.json');
12
+
9
13
  $.verbose = false;
10
14
 
11
15
  async function main() {
@@ -40,7 +44,6 @@ async function main() {
40
44
  }
41
45
 
42
46
  const skipPaths = await parseIgnoreFile(ignoreFilePath);
43
-
44
47
  if (argv.verbose) {
45
48
  console.log(bold('\n🚀 Batch Executor\n'));
46
49
  console.log(`Target directory: ${cyan(targetDir)}`);
@@ -69,7 +72,7 @@ async function main() {
69
72
 
70
73
  function printHelp() {
71
74
  console.log(`
72
- ${bold('Batch Executor')} ${dim('v1.3.0')}
75
+ ${bold('Batch Executor')} ${dim(`v${version}`)}
73
76
 
74
77
  ${cyan('Usage:')} batch-exec [options] <directory> <command> [args...]
75
78
 
@@ -4,10 +4,8 @@ import { shouldSkipDirectory } from './ignoreParser.js';
4
4
 
5
5
  export async function listDirectSubdirectories(targetDir, skipPatterns = []) {
6
6
  const absoluteTargetDir = path.resolve(targetDir);
7
-
8
7
  try {
9
8
  const entries = await fs.readdir(absoluteTargetDir, { withFileTypes: true });
10
-
11
9
  const subdirs = [];
12
10
 
13
11
  for (const entry of entries) {
@@ -8,7 +8,7 @@ export async function parseIgnoreFile(ignoreFilePath) {
8
8
 
9
9
  try {
10
10
  const content = await fs.readFile(ignoreFilePath, 'utf-8');
11
- const lines = content.split('\n');
11
+ const lines = content.split(/\r?\n/);
12
12
 
13
13
  return lines
14
14
  .map(line => line.trim())
File without changes