cdk-real-drift 0.2.78 → 0.2.79

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/cli.js CHANGED
@@ -55,6 +55,22 @@ import { DescribeDomainConfigCommand, OpenSearchClient, UpdateDomainConfigComman
55
55
  import { GetWebACLCommand, UpdateWebACLCommand, WAFV2Client } from "@aws-sdk/client-wafv2";
56
56
  import { ConfigServiceClient, DescribeConfigRulesCommand, PutConfigRuleCommand } from "@aws-sdk/client-config-service";
57
57
 
58
+ //#region src/exit.ts
59
+ function drain(stream) {
60
+ return new Promise((resolve) => {
61
+ if (stream.writableLength === 0 || stream.writableEnded) {
62
+ resolve();
63
+ return;
64
+ }
65
+ stream.write("", () => resolve());
66
+ });
67
+ }
68
+ async function flushAndExit(code) {
69
+ await Promise.all([drain(process.stdout), drain(process.stderr)]);
70
+ process.exit(code);
71
+ }
72
+
73
+ //#endregion
58
74
  //#region src/aws-errors.ts
59
75
  function isStackNotDeployed(e) {
60
76
  const msg = e?.message ?? String(e);
@@ -14325,13 +14341,13 @@ async function main(argv) {
14325
14341
  return 2;
14326
14342
  }
14327
14343
  }
14328
- main(process.argv.slice(2)).then((code) => process.exit(code)).catch((e) => {
14344
+ main(process.argv.slice(2)).then((code) => flushAndExit(code)).catch((e) => {
14329
14345
  const msg = e?.message ?? String(e);
14330
14346
  if (/credential|could not load cred|security token/i.test(msg)) console.error("error: no AWS credentials available. Configure them (aws configure / AWS_PROFILE / env vars) and retry.");
14331
14347
  else if (/stack/i.test(msg) && /(does not exist|ValidationError)/i.test(msg)) console.error("error: stack not found in this account/region. Check the stack name and --region.");
14332
14348
  else if (/AccessDenied|not authorized/i.test(msg)) console.error(`error: access denied — ${msg}`);
14333
14349
  else console.error(`error: ${msg}`);
14334
- process.exit(2);
14350
+ return flushAndExit(2);
14335
14351
  });
14336
14352
 
14337
14353
  //#endregion