-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathconfig.js
51 lines (45 loc) · 1.31 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict";
var Config,
fs = require( "node:fs" ),
path = require( "node:path" );
Config = module.exports = function() {
var config = Config.get();
// Validate jqueryUi, eg:
// "jqueryUi": [
// {
// "version": "1.14.1",
// "dependsOn": "jQuery 1.12+ / 2.2+ / 3.6+ / 4.0+",
// "label": "Stable",
// "stable": true
// },
// {
// "version": "1.13.3",
// "dependsOn": "jQuery 1.8+",
// "label": "Legacy"
// }
// ]
if ( config.jqueryUi == null ) {
throw new Error( "Missing jqueryUi branch/tag in config.json" );
}
if ( !Array.isArray( config.jqueryUi ) ) {
throw new Error( "Invalid jqueryUi branch/tag in config.json" );
}
config.jqueryUi = config.jqueryUi.map( function( entry ) {
if ( typeof entry !== "object" || !entry.version ) {
throw new Error( "Invalid jqueryUi entry " + JSON.stringify( entry ) + " in config.json" );
}
entry.ref = entry.version;
return entry;
} );
// Validate jquery
if ( config.jquery == null ) {
throw new Error( "Missing jquery version in config.json" );
}
if ( typeof config.jquery !== "string" ) {
throw new Error( "Invalid jquery version in config.json" );
}
return config;
};
Config.get = function() {
return JSON.parse( fs.readFileSync( path.join( __dirname, "../config.json" ) ) );
};