WIP
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { mkdirSync, writeFileSync } from 'fs';
|
||||
import { mkdirSync, writeFileSync, readFileSync } from 'fs';
|
||||
|
||||
// Rows to a CSV file. CSV_SEPARATOR is ';' by default. A cell is quoted
|
||||
// only when it holds the separator, a quote or a newline; a quote inside a
|
||||
@@ -23,4 +23,18 @@ export function writeCsv(name, csv) {
|
||||
const file = `${SHARE_DIR}/${name}`;
|
||||
writeFileSync(file, csv, 'utf8');
|
||||
return file;
|
||||
}
|
||||
|
||||
// The spec of the run, next to its CSV (same base name, .ttl), so a report
|
||||
// can be debugged afterwards. The store keeps only the pointer.
|
||||
export function writeSpec(csvName, spec) {
|
||||
mkdirSync(SHARE_DIR, { recursive: true });
|
||||
const name = csvName.replace(/\.csv$/, '') + '.ttl';
|
||||
writeFileSync(`${SHARE_DIR}/${name}`, spec, 'utf8');
|
||||
return `share://${name}`;
|
||||
}
|
||||
|
||||
export function readSpec(pointer) {
|
||||
if (!pointer.startsWith('share://')) throw new Error(`not a share:// pointer: ${pointer}`);
|
||||
return readFileSync(`${SHARE_DIR}/${pointer.slice('share://'.length)}`, 'utf8');
|
||||
}
|
||||
Reference in New Issue
Block a user