diff --git a/data/libraries/hlm b/data/libraries/hlm index 51e40dd8..ee02dc47 160000 --- a/data/libraries/hlm +++ b/data/libraries/hlm @@ -1 +1 @@ -Subproject commit 51e40dd85b12c3a1b10926a5568249c8a6fcc579 +Subproject commit ee02dc47faaddc60ffb504439bda6be200e3cec0 diff --git a/src/scripts/check.ts b/src/scripts/check.ts index 4dc71dcf..1521727f 100644 --- a/src/scripts/check.ts +++ b/src/scripts/check.ts @@ -110,18 +110,20 @@ function checkItem(libraryDefinition: LibraryDefinition, libraryDataProvider: Li }); } -if (process.argv.length !== 3) { +if (process.argv.length === 3) { + const libraryFileName = process.argv[2]; + checkLibrary(libraryFileName) + .then(() => { + console.error(`Found ${errorCount} error(s) and ${warningCount} warning(s).`); + if (unexpectedError) { + process.exitCode = 1; + } + }) + .catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} else { console.error('usage: src/scripts/check.sh '); - process.exit(2); + process.exitCode = 2; } - -const libraryFileName = process.argv[2]; -checkLibrary(libraryFileName) - .then(() => { - console.error(`Found ${errorCount} error(s) and ${warningCount} warning(s).`); - process.exit(unexpectedError ? 1 : 0); - }) - .catch((error) => { - console.error(error); - process.exit(1); - }); diff --git a/src/scripts/checkLinks.ts b/src/scripts/checkLinks.ts index e7c2f2d6..c6118f0f 100644 --- a/src/scripts/checkLinks.ts +++ b/src/scripts/checkLinks.ts @@ -11,6 +11,15 @@ const linkCheck = require('link-check'); let linksFound = 0; let linksChecking = 0; let linksChecked = 0; +let errors = 0; + +function finished(): void { + console.log(`${linksChecked} links checked.`); + if (errors) { + console.log(`${errors} error(s) found.`); + process.exitCode = 1; + } +} class LinkExtractor { constructor(private fileName: string) {} @@ -35,13 +44,15 @@ class LinkExtractor { linkCheck(uri, (err: any, result: any) => { if (err) { console.error(`${this.fileName}: ${err}`); + errors++; } else if (result.status !== 'alive') { console.error(`${this.fileName}: ${result.status} link: ${result.link}`); + errors++; } linksChecking--; linksChecked++; if (linksChecked === linksFound) { - console.log(`${linksChecked} links checked.`); + finished(); } }); } else { @@ -80,13 +91,12 @@ function checkLinks(fileName: string): void { } } -if (process.argv.length < 3) { +if (process.argv.length >= 3) { + for (const fileName of process.argv.slice(2)) { + checkLinks(fileName); + } + console.log(`${linksFound} links found.`); +} else { console.error('usage: src/scripts/checkLinks.sh [...]'); - process.exit(2); + process.exitCode = 2; } - -for (const fileName of process.argv.slice(2)) { - checkLinks(fileName); -} - -console.log(`${linksFound} links found.`); diff --git a/src/scripts/generateMetaDeclarations.ts b/src/scripts/generateMetaDeclarations.ts index 07ac6c1a..8757e0c5 100644 --- a/src/scripts/generateMetaDeclarations.ts +++ b/src/scripts/generateMetaDeclarations.ts @@ -1417,16 +1417,16 @@ function generate(inFileName: string, outFileName: string, referencedMetaModels: fs.writeFileSync(outFileName, outFileStr, 'utf8'); } -if (process.argv.length < 4) { +if (process.argv.length >= 4) { + const refs: ReferencedMetaModel[] = []; + for (let argIndex = 4; argIndex + 1 < process.argv.length; argIndex++) { + refs.push({ + inFileName: process.argv[argIndex], + outFileName: process.argv[argIndex + 1] + }); + } + generate(process.argv[2], process.argv[3], refs); +} else { console.error('usage: src/scripts/generateMetaDeclarations.sh [ [...]]'); - process.exit(2); -} - -const refs: ReferencedMetaModel[] = []; -for (let argIndex = 4; argIndex + 1 < process.argv.length; argIndex++) { - refs.push({ - inFileName: process.argv[argIndex], - outFileName: process.argv[argIndex + 1] - }); + process.exitCode = 2; } -generate(process.argv[2], process.argv[3], refs); diff --git a/src/scripts/tidy.ts b/src/scripts/tidy.ts index 52c3ba32..d4937684 100644 --- a/src/scripts/tidy.ts +++ b/src/scripts/tidy.ts @@ -24,11 +24,11 @@ function tidy(fileName: string): void { } } -if (process.argv.length < 3) { +if (process.argv.length >= 3) { + for (const fileName of process.argv.slice(2)) { + tidy(fileName); + } +} else { console.error('usage: src/scripts/tidy.sh [...]'); - process.exit(2); -} - -for (const fileName of process.argv.slice(2)) { - tidy(fileName); + process.exitCode = 2; } diff --git a/src/server/generic/static/buildPreload.ts b/src/server/generic/static/buildPreload.ts index 637a749b..dd47b116 100644 --- a/src/server/generic/static/buildPreload.ts +++ b/src/server/generic/static/buildPreload.ts @@ -28,13 +28,13 @@ function outputPreload(libraryFileName: string, outputDirName: string): CachedPr return preloadWriter.preloadLibrary(path.basename(libraryFileName, fileExtension)); } -if (process.argv.length !== 4) { +if (process.argv.length === 4) { + outputPreload(process.argv[2], process.argv[3]) + .catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} else { console.error('usage: node buildPreload.js '); - process.exit(2); + process.exitCode = 2; } - -outputPreload(process.argv[2], process.argv[3]) - .catch((error) => { - console.error(error); - process.exit(1); - }); diff --git a/src/server/generic/static/buildStatic.ts b/src/server/generic/static/buildStatic.ts index 7de02765..268a4cf0 100644 --- a/src/server/generic/static/buildStatic.ts +++ b/src/server/generic/static/buildStatic.ts @@ -250,13 +250,13 @@ function buildStaticPages(libraryFileName: string, logicName: string, htmlTempla .then(() => libraryDataProvider.close()); } -if (process.argv.length !== 9) { +if (process.argv.length === 9) { + buildStaticPages(process.argv[2], process.argv[3], process.argv[4], process.argv[5], process.argv[6], process.argv[7], process.argv[8]) + .catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} else { console.error('usage: node buildStatic.js '); - process.exit(2); + process.exitCode = 2; } - -buildStaticPages(process.argv[2], process.argv[3], process.argv[4], process.argv[5], process.argv[6], process.argv[7], process.argv[8]) - .catch((error) => { - console.error(error); - process.exit(1); - });