From c41c41d0e98437597e26572765e9807eabdb3b4c Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Fri, 1 Jan 2021 18:57:21 +0100 Subject: [PATCH] fix: Ensure root file path is absolute. --- src/init/CliRunner.ts | 4 ++-- test/unit/init/CliRunner.test.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/init/CliRunner.ts b/src/init/CliRunner.ts index 86f129b776..ebb50b19b2 100644 --- a/src/init/CliRunner.ts +++ b/src/init/CliRunner.ts @@ -37,7 +37,7 @@ export class CliRunner { mainModulePath: { type: 'string', alias: 'm' }, podTemplateFolder: { type: 'string', alias: 't' }, port: { type: 'number', alias: 'p', default: 3000 }, - rootFilePath: { type: 'string', alias: 'f' }, + rootFilePath: { type: 'string', alias: 'f', default: './' }, sparqlEndpoint: { type: 'string', alias: 's' }, }) .help(); @@ -85,7 +85,7 @@ export class CliRunner { params.baseUrl ? ensureTrailingSlash(params.baseUrl) : `http://localhost:${params.port}/`, 'urn:solid-server:default:variable:loggingLevel': params.loggingLevel, 'urn:solid-server:default:variable:port': params.port, - 'urn:solid-server:default:variable:rootFilePath': params.rootFilePath ?? process.cwd(), + 'urn:solid-server:default:variable:rootFilePath': this.resolvePath(params.rootFilePath), 'urn:solid-server:default:variable:sparqlEndpoint': params.sparqlEndpoint, 'urn:solid-server:default:variable:podTemplateFolder': params.podTemplateFolder ?? this.resolvePath(null, 'templates'), diff --git a/test/unit/init/CliRunner.test.ts b/test/unit/init/CliRunner.test.ts index 10fb3544be..c414d94e1c 100644 --- a/test/unit/init/CliRunner.test.ts +++ b/test/unit/init/CliRunner.test.ts @@ -45,7 +45,7 @@ describe('CliRunner', (): void => { variables: { 'urn:solid-server:default:variable:port': 3000, 'urn:solid-server:default:variable:baseUrl': 'http://localhost:3000/', - 'urn:solid-server:default:variable:rootFilePath': process.cwd(), + 'urn:solid-server:default:variable:rootFilePath': '/var/cwd/', 'urn:solid-server:default:variable:sparqlEndpoint': undefined, 'urn:solid-server:default:variable:loggingLevel': 'info', 'urn:solid-server:default:variable:podTemplateFolder': path.join(__dirname, '../../../templates'), @@ -90,7 +90,7 @@ describe('CliRunner', (): void => { 'urn:solid-server:default:variable:loggingLevel': 'debug', 'urn:solid-server:default:variable:podTemplateFolder': 'templates', 'urn:solid-server:default:variable:port': 4000, - 'urn:solid-server:default:variable:rootFilePath': '/root', + 'urn:solid-server:default:variable:rootFilePath': '/var/cwd/root', 'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql', }, }, @@ -108,7 +108,7 @@ describe('CliRunner', (): void => { '--mainModulePath', 'module/path', '--podTemplateFolder', 'templates', '--port', '4000', - '--rootFilePath', '/root', + '--rootFilePath', 'root', '--sparqlEndpoint', 'http://localhost:5000/sparql', ], }); @@ -129,7 +129,7 @@ describe('CliRunner', (): void => { 'urn:solid-server:default:variable:loggingLevel': 'debug', 'urn:solid-server:default:variable:podTemplateFolder': 'templates', 'urn:solid-server:default:variable:port': 4000, - 'urn:solid-server:default:variable:rootFilePath': '/root', + 'urn:solid-server:default:variable:rootFilePath': '/var/cwd/root', 'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql', }, },