UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

1 lines 3.68 kB
{"version":3,"sources":["../../src/commands/finalize/index.ts"],"names":["finalize","context","hooks","callHook","catch","error","log","LogLevelLabel","ERROR","message","stack","Error","cause","Promise","all","workers","errorLookup","end","configReflection","filter","Boolean","vfs","__VFS_REVERT__"],"mappings":";;;;;;AA6BA,eAAsBA,QAAAA,CAASC,SAAkBC,KAAAA,EAAkB;AACjE,EAAA,MAAMA,MAAMC,QAAAA,CAAS,gBAAA,EAAkBF,OAAAA,CAAAA,CAASG,KAAAA,CAAM,CAACC,KAAAA,KAAAA;AACrDJ,IAAAA,OAAAA,CAAQK,GAAAA,CACNC,mBAAAA,CAAcC,KAAAA,EACd,CAAA,kFAAA,EAAqFH,MAAMI,OAAO,CAAA;EAAMJ,KAAAA,CAAMK,KAAAA,IAAS,EAAA,CAAA,CAAI,CAAA;AAG7H,IAAA,MAAM,IAAIC,MACR,kFAAA,EACA;MAAEC,KAAAA,EAAOP;KAAM,CAAA;EAEnB,CAAA,CAAA;AAEA,EAAA,MAAMQ,QAAQC,GAAAA,CACZ;IACEb,OAAAA,CAAQc,OAAAA,CAAQC,aAAaC,GAAAA,EAAAA;IAC7BhB,OAAAA,CAAQc,OAAAA,CAAQG,kBAAkBD,GAAAA;AAClCE,GAAAA,CAAAA,MAAAA,CAAOC,OAAAA,CAAAA,CAAAA;AAGX,EAAA,MAAMlB,MAAMC,QAAAA,CAAS,mBAAA,EAAqBF,OAAAA,CAAAA,CAASG,KAAAA,CAAM,CAACC,KAAAA,KAAAA;AACxDJ,IAAAA,OAAAA,CAAQK,GAAAA,CACNC,mBAAAA,CAAcC,KAAAA,EACd,CAAA,mFAAA,EAAsFH,MAAMI,OAAO,CAAA;EAAMJ,KAAAA,CAAMK,KAAAA,IAAS,EAAA,CAAA,CAAI,CAAA;AAG9H,IAAA,MAAM,IAAIC,MACR,mFAAA,EACA;MAAEC,KAAAA,EAAOP;KAAM,CAAA;EAEnB,CAAA,CAAA;AAEAJ,EAAAA,OAAAA,CAAQoB,GAAAA,CAAIC,gCAAAA,CAAAA,EAAe;AAC7B;AAjCsBtB,wBAAAA,CAAAA,QAAAA,EAAAA,UAAAA,CAAAA","file":"chunk-ZQM2CFMT.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/storm-stack.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-stack\n Documentation: https://docs.stormsoftware.com/projects/storm-stack\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { EngineHooks } from \"../../types/build\";\nimport { Context } from \"../../types/context\";\nimport { __VFS_REVERT__ } from \"../../types/vfs\";\n\n/**\n * Finalizes the Storm Stack project by cleaning up resources and completing the build process.\n *\n * @param context - The build context.\n * @param hooks - The engine hooks.\n */\nexport async function finalize(context: Context, hooks: EngineHooks) {\n await hooks.callHook(\"finalize:begin\", context).catch((error: Error) => {\n context.log(\n LogLevelLabel.ERROR,\n `An error occured while starting the finalize process for the Storm Stack project: ${error.message} \\n${error.stack ?? \"\"}`\n );\n\n throw new Error(\n \"An error occured while starting the finalize process for the Storm Stack project\",\n { cause: error }\n );\n });\n\n await Promise.all(\n [\n context.workers.errorLookup?.end(),\n context.workers.configReflection?.end()\n ].filter(Boolean)\n );\n\n await hooks.callHook(\"finalize:complete\", context).catch((error: Error) => {\n context.log(\n LogLevelLabel.ERROR,\n `An error occured while finishing the finalize process for the Storm Stack project: ${error.message} \\n${error.stack ?? \"\"}`\n );\n\n throw new Error(\n \"An error occured while finishing the finalize process for the Storm Stack project\",\n { cause: error }\n );\n });\n\n context.vfs[__VFS_REVERT__]();\n}\n"]}