@@ -11,6 +11,12 @@ import path from 'node:path'
1111import { execSync } from 'node:child_process'
1212import { scriptError } from '@spongex/script-error'
1313
14+ // Job interface
15+ interface job {
16+ name: string
17+ path: string
18+ }
19+
1420const colors = {
1521 RED : `\x1b[31m` ,
1622 GREEN : `\x1b[32m` ,
@@ -28,20 +34,26 @@ const constants = {
2834}
2935
3036/**
31- * Load local settings file
37+ * Load local settings file - exit script on fail.
3238 * @param SETTINGS_FILE File to load
33- * @param noerror Pass true to ignore the script error
3439 * @returns Settings JSON object
35- * @throws Error on fail then exits script
3640 */
37- export const loadSettings = ( SETTINGS_FILE :string , noerror ? : boolean ) => {
41+ export const loadSettings = ( SETTINGS_FILE :string ) => {
3842 try {
3943 return JSON . parse ( fs . readFileSync ( path . normalize ( SETTINGS_FILE ) ) . toString ( ) )
4044 } catch ( error ) {
41- if ( ! noerror ) scriptError ( `Can't find a '${ SETTINGS_FILE } ' configuration file.` )
45+ scriptError ( `Can't find a local '${ SETTINGS_FILE } ' configuration file.` )
4246 }
4347}
4448
4549console . log ( `${ colors . GREEN } Building binaries...${ colors . CLEAR } ` )
4650
47- var settings = loadSettings ( `${ process . cwd ( ) } /${ constants . SETTINGS_FILE } ` , true )
51+ var settings = loadSettings ( `${ process . cwd ( ) } /${ constants . SETTINGS_FILE } ` )
52+
53+ if ( ! ( settings [ 'jobs' ] instanceof Array ) ) scriptError ( `No Jobs defined.` )
54+
55+ settings [ 'jobs' ] . forEach ( ( job :job , IDX :number ) => {
56+ if ( job . name === undefined || job . path === undefined )
57+ scriptError ( `Job ${ IDX + 1 } of ${ settings [ 'jobs' ] . length } incorrect format.` )
58+ execSync ( `` )
59+ } )
0 commit comments