diff --git a/src-script/unify-regen.js b/src-script/unify-regen.js index 78cd86d18b..70ff69daf2 100644 --- a/src-script/unify-regen.js +++ b/src-script/unify-regen.js @@ -23,8 +23,7 @@ const scriptUtil = require('./script-util') const unifySdkPath = process.argv[2] if (!unifySdkPath) { - console.error('Missing Argument. Usage: unify-regen.js ') - process.exit(1) + throw Error('Missing Argument. Usage: unify-regen.js ') } async function generateZapFiles() { @@ -33,6 +32,8 @@ async function generateZapFiles() { const zclFile = `${unifySdkPath}components/uic_dotdot/dotdot-xml/library.xml` if (!fs.existsSync(zclFile)) { throw Error(`Invalid Zcl File ${zclFile} does not exist.`) + } else { + console.log(`👍 ZCL metafile: ${zclFile}`) } // get all template files in the unify sdk @@ -40,6 +41,14 @@ async function generateZapFiles() { unifySdkPath, 'gen-templates.json' ) + if (templateFiles.length === 0) { + throw Error(`No template files found in ${unifySdkPath}`) + } else { + console.log(`👍 Found ${templateFiles.length} template files.`) + } + + // get ZAP main path + const zapCli = scriptUtil.mainPath(false) for (const templateFile of templateFiles) { // get the output directory as per unify sdk structure @@ -49,8 +58,6 @@ async function generateZapFiles() { ) fs.rmSync(outputDir, { recursive: true, force: true }) - const zapCli = scriptUtil.mainPath(false) - let cmdArgs = [ 'node', scriptUtil.mainPath(false), @@ -67,7 +74,7 @@ async function generateZapFiles() { await scriptUtil.executeCmd(null, 'npx', cmdArgs) } } catch (error) { - console.error('An error occurred during the ZAP generation process:', error) + throw Error('An error occurred during the ZAP generation process:', error) } }