mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: allow custom config to be passed
This commit is contained in:
parent
f08e97b80c
commit
09707a9e6d
@ -1,3 +1,4 @@
|
||||
import * as Path from 'path';
|
||||
import { ReadStream, WriteStream } from 'tty';
|
||||
import { Loader, LoaderProperties } from 'componentsjs';
|
||||
import yargs from 'yargs';
|
||||
@ -23,15 +24,21 @@ export const runCustom = function(
|
||||
.usage('node ./bin/server.js [args]')
|
||||
.options({
|
||||
port: { type: 'number', alias: 'p' },
|
||||
config: { type: 'string', alias: 'c' },
|
||||
})
|
||||
.help();
|
||||
|
||||
new Promise<RuntimeConfig>(async(resolve): Promise<void> => {
|
||||
// Load provided or default config file
|
||||
const configPath = argv.config ?
|
||||
Path.join(process.cwd(), argv.config) :
|
||||
`${__dirname}/../../config/config-default.json`;
|
||||
|
||||
// Setup from config file
|
||||
const loader = new Loader(properties);
|
||||
await loader.registerAvailableModuleResources();
|
||||
const setup: Setup = await loader
|
||||
.instantiateFromUrl('urn:solid-server:my', `${__dirname}/../../config/config-default.json`);
|
||||
.instantiateFromUrl('urn:solid-server:my', configPath);
|
||||
resolve(await setup.setup({ port: argv.port }));
|
||||
}).then((runtimeConfig: RuntimeConfig): void => {
|
||||
stdout.write(`Running at ${runtimeConfig.base}\n`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user