gitfleet 1.1.1 → 1.1.3

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/commands/pull.js CHANGED
@@ -3,24 +3,37 @@ const { exec } = require("child_process");
3
3
 
4
4
  function runGit(repo, command) {
5
5
  return new Promise((resolve, reject) => {
6
+
6
7
  exec(`git -C "${repo}" ${command}`, (err, stdout, stderr) => {
8
+
7
9
  if (err) {
8
- console.error(`❌ ${repo}`);
10
+ console.log(`❌ ${repo}`);
11
+ console.log(stderr || err.message);
9
12
  return reject(err);
10
13
  }
11
14
 
12
15
  console.log(`✔ ${repo}`);
16
+
17
+ if (stdout.trim()) {
18
+ console.log(stdout.trim());
19
+ }
20
+
13
21
  resolve(stdout);
22
+
14
23
  });
24
+
15
25
  });
16
26
  }
17
27
 
18
28
  async function pullRepos(repos) {
19
- await runWorkerPool(
29
+
30
+ const results = await runWorkerPool(
20
31
  repos,
21
32
  (repo) => runGit(repo, "pull"),
22
33
  4
23
34
  );
35
+
36
+ return results;
24
37
  }
25
38
 
26
39
  module.exports = pullRepos;
@@ -1,22 +1,29 @@
1
1
  const pLimit = require("p-limit");
2
-
3
2
  const os = require("os");
4
- const workers = os.cpus().length * 2;
5
3
 
6
4
  /**
7
5
  * Run tasks in parallel with limited concurrency
8
- * @param {Array} items - list of items (repos)
9
- * @param {Function} task - async function to run per item
10
- * @param {number} workers - number of parallel workers
6
+ * @param {Array} items
7
+ * @param {Function} task
8
+ * @param {number} concurrency
11
9
  */
12
- async function runWorkerPool(items, task, workers=4) {
13
- const limit = pLimit(workers);
10
+ async function runWorkerPool(items, task, concurrency = os.cpus().length) {
11
+
12
+ const limit = pLimit(concurrency);
14
13
 
15
14
  const tasks = items.map(item =>
16
- limit(() => task(item))
15
+ limit(async () => {
16
+ try {
17
+ const result = await task(item);
18
+ return { item, success: true, result };
19
+ } catch (err) {
20
+ return { item, success: false, error: err };
21
+ }
22
+ })
17
23
  );
18
24
 
19
25
  return Promise.allSettled(tasks);
20
26
  }
21
27
 
28
+
22
29
  module.exports = { runWorkerPool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitfleet",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"