From 801c734575b079c24b18535d3d20b8f18828af6f Mon Sep 17 00:00:00 2001 From: kreuzerk Date: Sun, 25 Oct 2020 18:28:28 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20handle=20exception=20and?= =?UTF-8?q?=20quit=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/svg-icons-builder/index.ts | 42 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/svg-icons-builder/index.ts b/src/svg-icons-builder/index.ts index 1592251..3f9dbc1 100644 --- a/src/svg-icons-builder/index.ts +++ b/src/svg-icons-builder/index.ts @@ -21,27 +21,33 @@ interface Options extends CommonConversionOptions, JsonObject { export default createBuilder((conversionOptions: Options, context: BuilderContext) => { return new Promise(async (resolve, reject) => { - if (!conversionOptions) { - reject(); - } + try { + if (!conversionOptions) { + reject(); + } - if (conversionOptions.conversionType === ConversionType.FILES) { - context.logger.info('We are using the conversion type "files"'); - await convertToFiles((conversionOptions as unknown) as FileConversionOptions); - } + if (conversionOptions.conversionType === ConversionType.FILES) { + context.logger.info('We are using the conversion type "files"'); + await convertToFiles((conversionOptions as unknown) as FileConversionOptions); + } - if (conversionOptions.conversionType === ConversionType.CONSTANTS) { - context.logger.info('We are using the conversion type "constants"'); - await convertToConstants((conversionOptions as unknown) as ConstantsConversionOptions); - } + if (conversionOptions.conversionType === ConversionType.CONSTANTS) { + context.logger.info('We are using the conversion type "constants"'); + await convertToConstants((conversionOptions as unknown) as ConstantsConversionOptions); + } - if (conversionOptions.conversionType === ConversionType.OBJECT) { - context.logger.info('We are using the conversion type "object"'); - await convertToSingleObject((conversionOptions as unknown) as ObjectConversionOptions); - } + if (conversionOptions.conversionType === ConversionType.OBJECT) { + context.logger.info('We are using the conversion type "object"'); + await convertToSingleObject((conversionOptions as unknown) as ObjectConversionOptions); + } - resolve(); - context.reportStatus(`Done.`); - process.exit(0); + resolve(); + context.reportStatus(`Done.`); + process.disconnect(); + process.exit(0); + } catch (error) { + process.disconnect(); + process.exit(1); + } }); });