@nmakarov/cli-toolkit 0.51.0 → 0.53.0

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/dist/init.cjs CHANGED
@@ -2648,7 +2648,10 @@ async function init(flow, opts = {}) {
2648
2648
  context.isStop = () => stop;
2649
2649
  context = await setupModules(context, opts);
2650
2650
  const stopAfter = context.args.get("stopAfter");
2651
- const stopAllowance = context.params.get("stopAllowance", "number default 5");
2651
+ const stopAllowanceSec = Number(context.params.get("stopAllowance", "number default 60"));
2652
+ const stopAllowanceMs = (Number.isFinite(stopAllowanceSec) && stopAllowanceSec >= 0 ? stopAllowanceSec : 60) * 1e3;
2653
+ context.stopAllowanceSec = stopAllowanceSec;
2654
+ context.stopAllowanceMs = stopAllowanceMs;
2652
2655
  if (stopAfter === "init") {
2653
2656
  printAllParameters(context);
2654
2657
  process.exit(0);
@@ -2662,8 +2665,10 @@ async function init(flow, opts = {}) {
2662
2665
  sigintCount = 1;
2663
2666
  firstSigintAt = now;
2664
2667
  stop = true;
2665
- context.logger.info(`>> emitting stop with allowance ${stopAllowance}`);
2666
- context.emitter.emit("stop", stopAllowance);
2668
+ context.logger.info(
2669
+ `>> emitting stop with allowance ${stopAllowanceSec}s (${stopAllowanceMs}ms)`
2670
+ );
2671
+ context.emitter.emit("stop", stopAllowanceMs);
2667
2672
  return;
2668
2673
  }
2669
2674
  if (now - firstSigintAt < 250) return;
@@ -2674,8 +2679,10 @@ async function init(flow, opts = {}) {
2674
2679
  process.on("SIGTERM", () => {
2675
2680
  if (!context || stop) return;
2676
2681
  stop = true;
2677
- context.logger.info(`>> SIGTERM: emitting stop with allowance ${stopAllowance}`);
2678
- context.emitter.emit("stop", stopAllowance);
2682
+ context.logger.info(
2683
+ `>> SIGTERM: emitting stop with allowance ${stopAllowanceSec}s (${stopAllowanceMs}ms)`
2684
+ );
2685
+ context.emitter.emit("stop", stopAllowanceMs);
2679
2686
  });
2680
2687
  await flow(context);
2681
2688
  } catch (error) {