8362e41b0e
Left to do: - test out including commit hash, when ruben finishes implementing this in the API. - screenshot reconciliation.
39 lines
856 B
JavaScript
39 lines
856 B
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const minimist = require('minimist');
|
|
|
|
const proto = {};
|
|
const config = Object.create(proto);
|
|
module.exports = config;
|
|
|
|
const layers = {};
|
|
const layord = 'default conffile gitjson gitlua cmdline'.split(' ');
|
|
|
|
function set(name, obj) {
|
|
if(!layord.find(x => x === name))
|
|
throw Error('invalid config layer name');
|
|
layers[name] = obj;
|
|
|
|
Object.keys(config)
|
|
.forEach(k => delete config[k]);
|
|
layord.forEach(k => Object.assign(config, layers[k] || {}));
|
|
return config;
|
|
}
|
|
proto.set = set;
|
|
|
|
set('cmdline', minimist(process.argv.slice(2)));
|
|
|
|
set('default', {
|
|
conf: path.join(process.env.HOME, '.cdbrelease.json'),
|
|
branch: 'master',
|
|
execlua: 'lua5.1',
|
|
cdbjsonpath: '.cdb.json',
|
|
cdbluapath: '.cdbrelease.lua',
|
|
root: 'https://content.minetest.net/api',
|
|
token: null,
|
|
user: null,
|
|
pkg: null,
|
|
timeout: 60,
|
|
});
|