@nmakarov/cli-toolkit 0.50.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.js CHANGED
@@ -2623,7 +2623,10 @@ async function init(flow, opts = {}) {
2623
2623
  context.isStop = () => stop;
2624
2624
  context = await setupModules(context, opts);
2625
2625
  const stopAfter = context.args.get("stopAfter");
2626
- const stopAllowance = context.params.get("stopAllowance", "number default 5");
2626
+ const stopAllowanceSec = Number(context.params.get("stopAllowance", "number default 60"));
2627
+ const stopAllowanceMs = (Number.isFinite(stopAllowanceSec) && stopAllowanceSec >= 0 ? stopAllowanceSec : 60) * 1e3;
2628
+ context.stopAllowanceSec = stopAllowanceSec;
2629
+ context.stopAllowanceMs = stopAllowanceMs;
2627
2630
  if (stopAfter === "init") {
2628
2631
  printAllParameters(context);
2629
2632
  process.exit(0);
@@ -2637,8 +2640,10 @@ async function init(flow, opts = {}) {
2637
2640
  sigintCount = 1;
2638
2641
  firstSigintAt = now;
2639
2642
  stop = true;
2640
- context.logger.info(`>> emitting stop with allowance ${stopAllowance}`);
2641
- context.emitter.emit("stop", stopAllowance);
2643
+ context.logger.info(
2644
+ `>> emitting stop with allowance ${stopAllowanceSec}s (${stopAllowanceMs}ms)`
2645
+ );
2646
+ context.emitter.emit("stop", stopAllowanceMs);
2642
2647
  return;
2643
2648
  }
2644
2649
  if (now - firstSigintAt < 250) return;
@@ -2649,8 +2654,10 @@ async function init(flow, opts = {}) {
2649
2654
  process.on("SIGTERM", () => {
2650
2655
  if (!context || stop) return;
2651
2656
  stop = true;
2652
- context.logger.info(`>> SIGTERM: emitting stop with allowance ${stopAllowance}`);
2653
- context.emitter.emit("stop", stopAllowance);
2657
+ context.logger.info(
2658
+ `>> SIGTERM: emitting stop with allowance ${stopAllowanceSec}s (${stopAllowanceMs}ms)`
2659
+ );
2660
+ context.emitter.emit("stop", stopAllowanceMs);
2654
2661
  });
2655
2662
  await flow(context);
2656
2663
  } catch (error) {