This repository was archived by the owner on Feb 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (44 loc) · 1.48 KB
/
index.js
File metadata and controls
50 lines (44 loc) · 1.48 KB
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
/**
* This is the intended entry-point for Regent when the package is used as a
* dependency. This file handles the configuration and bootstrapping of the
* Regent package, and fills in some sensible (yet configurable) options.
*
* @author Steven Jimenez
*/
'use strict';
const DefaultConfig = require('regent-js/etc/default');
const Regent = require('regent-js/lib/core/regent');
const ObjectMerger = require('regent-js/lib/util/object-merger');
const { resolve } = require('path');
const inlineRequire = require;
const rootDir = __dirname;
// Configure (but do not start) a Regent instance
function create(appDir = rootDir, SystemConfig = {}, AppConfig = null) {
const merger = new ObjectMerger();
const interimConfig = {
Directories: {
app: resolve(`${appDir}/app`),
log: resolve(`${appDir}/storage/log`),
},
};
SystemConfig = merger.merge(
{},
DefaultConfig,
interimConfig,
SystemConfig,
);
if (!AppConfig) {
AppConfig = (SystemConfig.AppConfig && SystemConfig.AppConfig.file)
? AppConfig = inlineRequire(SystemConfig.AppConfig.file)
: SystemConfig.AppConfig || {};
}
return new Regent(SystemConfig, AppConfig);
}
// Configure and start Regent as a dependency
function start(appDir = rootDir, SystemConfig = {}, LocalConfig = null) {
return create(appDir, SystemConfig, LocalConfig).start();
}
module.exports = {
create,
start,
};