mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Join and normalize paths consistently.
This commit is contained in:
committed by
Joachim Van Herwegen
parent
ee072b038a
commit
f454b781ff
@@ -1,8 +1,7 @@
|
||||
import { mkdirSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import * as Path from 'path';
|
||||
import { Loader } from 'componentsjs';
|
||||
import * as rimraf from 'rimraf';
|
||||
import { joinFilePath, toSystemFilePath } from '../../src/util/PathUtil';
|
||||
|
||||
export const BASE = 'http://test.com';
|
||||
|
||||
@@ -12,17 +11,17 @@ export const BASE = 'http://test.com';
|
||||
export const instantiateFromConfig = async(componentUrl: string, configFile: string,
|
||||
variables?: Record<string, any>): Promise<any> => {
|
||||
// Initialize the Components.js loader
|
||||
const mainModulePath = Path.join(__dirname, '../../');
|
||||
const mainModulePath = joinFilePath(__dirname, '../../');
|
||||
const loader = new Loader({ mainModulePath });
|
||||
await loader.registerAvailableModuleResources();
|
||||
|
||||
// Instantiate the component from the config
|
||||
const configPath = Path.join(__dirname, 'config', configFile);
|
||||
const configPath = toSystemFilePath(joinFilePath(__dirname, 'config', configFile));
|
||||
return loader.instantiateFromUrl(componentUrl, configPath, undefined, { variables });
|
||||
};
|
||||
|
||||
export const getTestFolder = (name: string): string =>
|
||||
join(__dirname, '../tmp', name);
|
||||
joinFilePath(__dirname, '../tmp', name);
|
||||
|
||||
export const createFolder = (folder: string): void => {
|
||||
mkdirSync(folder, { recursive: true });
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createReadStream } from 'fs';
|
||||
import { join } from 'path';
|
||||
import type { HttpHandler, Initializer, ResourceStore } from '../../src/';
|
||||
import { RepresentationMetadata } from '../../src/ldp/representation/RepresentationMetadata';
|
||||
import { guardStream } from '../../src/util/GuardedStream';
|
||||
import { CONTENT_TYPE, LDP } from '../../src/util/Vocabularies';
|
||||
import {
|
||||
CONTENT_TYPE, LDP,
|
||||
RepresentationMetadata, guardStream, joinFilePath,
|
||||
} from '../../src/';
|
||||
import { AclHelper, ResourceHelper } from '../util/TestHelpers';
|
||||
import { BASE, getTestFolder, createFolder, removeFolder, instantiateFromConfig } from './Config';
|
||||
|
||||
@@ -58,7 +58,7 @@ describe.each(stores)('An LDP handler with auth using %s', (name, { storeUrn, se
|
||||
// Write test resource
|
||||
await store.setRepresentation({ path: `${BASE}/permanent.txt` }, {
|
||||
binary: true,
|
||||
data: guardStream(createReadStream(join(__dirname, '../assets/permanent.txt'))),
|
||||
data: guardStream(createReadStream(joinFilePath(__dirname, '../assets/permanent.txt'))),
|
||||
metadata: new RepresentationMetadata({ [CONTENT_TYPE]: 'text/plain' }),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Server } from 'http';
|
||||
import { join } from 'path';
|
||||
import fetch from 'cross-fetch';
|
||||
import type { HttpServerFactory } from '../../src/server/HttpServerFactory';
|
||||
import { joinFilePath } from '../../src/util/PathUtil';
|
||||
import { readableToString } from '../../src/util/StreamUtil';
|
||||
import { instantiateFromConfig } from './Config';
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('A server with a pod handler', (): void => {
|
||||
'urn:solid-server:default:ServerFactory', 'server-without-auth.json', {
|
||||
'urn:solid-server:default:variable:port': port,
|
||||
'urn:solid-server:default:variable:baseUrl': baseUrl,
|
||||
'urn:solid-server:default:variable:podTemplateFolder': join(__dirname, '../assets/templates'),
|
||||
'urn:solid-server:default:variable:podTemplateFolder': joinFilePath(__dirname, '../assets/templates'),
|
||||
},
|
||||
) as HttpServerFactory;
|
||||
server = factory.startServer(port);
|
||||
|
||||
Reference in New Issue
Block a user