Skip to content

Commit

Permalink
fix: Catalog path on Windows (#1106)
Browse files Browse the repository at this point in the history
* fix: Catalog path on Windows

* Fix another location

* Fix globby on Windows

* Use single slash

* CS
  • Loading branch information
ddeboer committed Sep 11, 2023
1 parent 6cd0d1f commit f034ba8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/network-of-terms-catalog/src/getCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import rdfParser from 'rdf-parse';
import * as RDF from '@rdfjs/types';
import {QueryEngine} from '@comunica/query-sparql-rdfjs';
import {Transform, TransformCallback} from 'stream';
import {dirname, resolve} from 'path';
import {globby} from 'globby';
import {storeStream} from 'rdf-store-stream';
import {
Expand All @@ -21,8 +20,9 @@ import {BindingsFactory} from '@comunica/bindings-factory';
import {Bindings} from '@rdfjs/types';

export async function getCatalog(path?: string): Promise<Catalog> {
const directory =
path ?? resolve(dirname(fileURLToPath(import.meta.url)), '../', 'catalog/');
const directory = (
path ?? fileURLToPath(new URL('../catalog', import.meta.url))
).replace(/\\/g, '/'); // Windows compatibility.
const store = await fromFiles(directory);
return fromStore(store);
}
Expand Down Expand Up @@ -156,10 +156,8 @@ class InlineFiles extends Transform {
callback: TransformCallback
) {
if (quad.object.value.startsWith('file://')) {
const file = resolve(
dirname(fileURLToPath(import.meta.url)),
'../',
quad.object.value.substr(7)
const file = fileURLToPath(
new URL('../' + quad.object.value.substr(7), import.meta.url)
);
quad.object.value = await fs.promises.readFile(file, 'utf-8');
}
Expand Down

0 comments on commit f034ba8

Please sign in to comment.