Skip to content

Commit

Permalink
feat: allow custom config to be passed
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Aug 28, 2020
1 parent 92830bb commit 6183343
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/init/CliRunner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Path from 'path';
import { ReadStream, WriteStream } from 'tty';
import { Loader, LoaderProperties } from 'componentsjs';
import yargs from 'yargs';
Expand All @@ -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`);
Expand Down

0 comments on commit 6183343

Please sign in to comment.