@builderbot/cli 1.3.12 → 1.3.14

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.
Files changed (2) hide show
  1. package/dist/index.cjs +53 -32
  2. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -1251,7 +1251,7 @@ function retry () {
1251
1251
  }
1252
1252
  }
1253
1253
 
1254
- (function (exports) {
1254
+ (function (exports$1) {
1255
1255
  // This is adapted from https://github.com/normalize/mz
1256
1256
  // Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
1257
1257
  const u = universalify$1.fromCallback;
@@ -1306,16 +1306,16 @@ function retry () {
1306
1306
  });
1307
1307
 
1308
1308
  // Export cloned fs:
1309
- Object.assign(exports, fs);
1309
+ Object.assign(exports$1, fs);
1310
1310
 
1311
1311
  // Universalify async methods:
1312
1312
  api.forEach(method => {
1313
- exports[method] = u(fs[method]);
1313
+ exports$1[method] = u(fs[method]);
1314
1314
  });
1315
1315
 
1316
1316
  // We differ from mz/fs in that we still ship the old, broken, fs.exists()
1317
1317
  // since we are a drop-in replacement for the native module
1318
- exports.exists = function (filename, callback) {
1318
+ exports$1.exists = function (filename, callback) {
1319
1319
  if (typeof callback === 'function') {
1320
1320
  return fs.exists(filename, callback)
1321
1321
  }
@@ -1326,7 +1326,7 @@ function retry () {
1326
1326
 
1327
1327
  // fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
1328
1328
 
1329
- exports.read = function (fd, buffer, offset, length, position, callback) {
1329
+ exports$1.read = function (fd, buffer, offset, length, position, callback) {
1330
1330
  if (typeof callback === 'function') {
1331
1331
  return fs.read(fd, buffer, offset, length, position, callback)
1332
1332
  }
@@ -1343,7 +1343,7 @@ function retry () {
1343
1343
  // OR
1344
1344
  // fs.write(fd, string[, position[, encoding]], callback)
1345
1345
  // We need to handle both cases, so we use ...args
1346
- exports.write = function (fd, buffer, ...args) {
1346
+ exports$1.write = function (fd, buffer, ...args) {
1347
1347
  if (typeof args[args.length - 1] === 'function') {
1348
1348
  return fs.write(fd, buffer, ...args)
1349
1349
  }
@@ -1359,7 +1359,7 @@ function retry () {
1359
1359
  // Function signature is
1360
1360
  // s.readv(fd, buffers[, position], callback)
1361
1361
  // We need to handle the optional arg, so we use ...args
1362
- exports.readv = function (fd, buffers, ...args) {
1362
+ exports$1.readv = function (fd, buffers, ...args) {
1363
1363
  if (typeof args[args.length - 1] === 'function') {
1364
1364
  return fs.readv(fd, buffers, ...args)
1365
1365
  }
@@ -1375,7 +1375,7 @@ function retry () {
1375
1375
  // Function signature is
1376
1376
  // s.writev(fd, buffers[, position], callback)
1377
1377
  // We need to handle the optional arg, so we use ...args
1378
- exports.writev = function (fd, buffers, ...args) {
1378
+ exports$1.writev = function (fd, buffers, ...args) {
1379
1379
  if (typeof args[args.length - 1] === 'function') {
1380
1380
  return fs.writev(fd, buffers, ...args)
1381
1381
  }
@@ -1390,7 +1390,7 @@ function retry () {
1390
1390
 
1391
1391
  // fs.realpath.native sometimes not available if fs is monkey-patched
1392
1392
  if (typeof fs.realpath.native === 'function') {
1393
- exports.realpath.native = u(fs.realpath.native);
1393
+ exports$1.realpath.native = u(fs.realpath.native);
1394
1394
  } else {
1395
1395
  process.emitWarning(
1396
1396
  'fs.realpath.native is not a function. Is fs being monkey-patched?',
@@ -1665,12 +1665,41 @@ var stat$4 = {
1665
1665
  areIdentical: areIdentical$2
1666
1666
  };
1667
1667
 
1668
+ // https://github.com/jprichardson/node-fs-extra/issues/1056
1669
+ // Performing parallel operations on each item of an async iterator is
1670
+ // surprisingly hard; you need to have handlers in place to avoid getting an
1671
+ // UnhandledPromiseRejectionWarning.
1672
+ // NOTE: This function does not presently handle return values, only errors
1673
+ async function asyncIteratorConcurrentProcess$1 (iterator, fn) {
1674
+ const promises = [];
1675
+ for await (const item of iterator) {
1676
+ promises.push(
1677
+ fn(item).then(
1678
+ () => null,
1679
+ (err) => err ?? new Error('unknown error')
1680
+ )
1681
+ );
1682
+ }
1683
+ await Promise.all(
1684
+ promises.map((promise) =>
1685
+ promise.then((possibleErr) => {
1686
+ if (possibleErr !== null) throw possibleErr
1687
+ })
1688
+ )
1689
+ );
1690
+ }
1691
+
1692
+ var async = {
1693
+ asyncIteratorConcurrentProcess: asyncIteratorConcurrentProcess$1
1694
+ };
1695
+
1668
1696
  const fs$b = fs$h;
1669
1697
  const path$9 = require$$1;
1670
1698
  const { mkdirs: mkdirs$1 } = mkdirs$2;
1671
1699
  const { pathExists: pathExists$5 } = pathExists_1;
1672
1700
  const { utimesMillis } = utimes;
1673
1701
  const stat$3 = stat$4;
1702
+ const { asyncIteratorConcurrentProcess } = async;
1674
1703
 
1675
1704
  async function copy$2 (src, dest, opts = {}) {
1676
1705
  if (typeof opts === 'function') {
@@ -1778,28 +1807,20 @@ async function onDir$1 (srcStat, destStat, src, dest, opts) {
1778
1807
  await fs$b.mkdir(dest);
1779
1808
  }
1780
1809
 
1781
- const promises = [];
1782
-
1783
- // loop through the files in the current directory to copy everything
1784
- for await (const item of await fs$b.opendir(src)) {
1810
+ // iterate through the files in the current directory to copy everything
1811
+ await asyncIteratorConcurrentProcess(await fs$b.opendir(src), async (item) => {
1785
1812
  const srcItem = path$9.join(src, item.name);
1786
1813
  const destItem = path$9.join(dest, item.name);
1787
1814
 
1788
- promises.push(
1789
- runFilter(srcItem, destItem, opts).then(include => {
1790
- if (include) {
1791
- // only copy the item if it matches the filter function
1792
- return stat$3.checkPaths(srcItem, destItem, 'copy', opts).then(({ destStat }) => {
1793
- // If the item is a copyable file, `getStatsAndPerformCopy` will copy it
1794
- // If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
1795
- return getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
1796
- })
1797
- }
1798
- })
1799
- );
1800
- }
1801
-
1802
- await Promise.all(promises);
1815
+ const include = await runFilter(srcItem, destItem, opts);
1816
+ // only copy the item if it matches the filter function
1817
+ if (include) {
1818
+ const { destStat } = await stat$3.checkPaths(srcItem, destItem, 'copy', opts);
1819
+ // If the item is a copyable file, `getStatsAndPerformCopy` will copy it
1820
+ // If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
1821
+ await getStatsAndPerformCopy(destStat, srcItem, destItem, opts);
1822
+ }
1823
+ });
1803
1824
 
1804
1825
  if (!destStat) {
1805
1826
  await fs$b.chmod(dest, srcStat.mode);
@@ -5665,9 +5686,9 @@ var hasRequiredPrompts$1;
5665
5686
  function requirePrompts$1 () {
5666
5687
  if (hasRequiredPrompts$1) return prompts$3;
5667
5688
  hasRequiredPrompts$1 = 1;
5668
- (function (exports) {
5689
+ (function (exports$1) {
5669
5690
 
5670
- const $ = exports;
5691
+ const $ = exports$1;
5671
5692
 
5672
5693
  const el = requireElements$1();
5673
5694
 
@@ -8633,8 +8654,8 @@ var hasRequiredPrompts;
8633
8654
  function requirePrompts () {
8634
8655
  if (hasRequiredPrompts) return prompts$2;
8635
8656
  hasRequiredPrompts = 1;
8636
- (function (exports) {
8637
- const $ = exports;
8657
+ (function (exports$1) {
8658
+ const $ = exports$1;
8638
8659
  const el = requireElements();
8639
8660
  const noop = v => v;
8640
8661
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builderbot/cli",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "types": "dist/index.d.ts",
@@ -41,5 +41,5 @@
41
41
  "type": "git",
42
42
  "url": "https://github.com/codigoencasa/bot-whatsapp/tree/main/packages/cli"
43
43
  },
44
- "gitHead": "f77370409931079e02a03e5bc9f6f2f15bdf26a0"
44
+ "gitHead": "b9bacfa917364b27d22fe7398c1219cbd28b2a22"
45
45
  }