Skip to content

Commit 8b941b7

Browse files
committed
sync
1 parent 5f190d1 commit 8b941b7

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

godot-builder/src/godot-builder.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import path from 'node:path'
1111
import { execSync } from 'node:child_process'
1212
import { scriptError } from '@spongex/script-error'
1313

14+
// Job interface
15+
interface job {
16+
name: string
17+
path: string
18+
}
19+
1420
const 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

4549
console.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

Comments
 (0)