Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 72x 72x 813x 15x 15x 15x 63x 63x 63x 63x 48x 48x 15x 13x 13x 15x 15x 813x 17x 17x 17x 2x 2x 17x 1x 1x 17x 17x 17x 1x 1x 15x 17x 813x 15x 15x 15x 14x 14x 14x 14x 14x 14x 19x 19x 1x 1x 18x 18x 19x 1x 1x 17x 17x 11x 15x 813x 72x | 'use strict';
module.exports = ({ external: { fs, path, processEnvironment, currentWorkingDirectory }, }) => {
function configurationPaths() {
const candidates = [];
let directory = path.resolve(currentWorkingDirectory());
while (true) {
candidates.push(path.join(directory, '.ledlightrc'));
const parent = path.dirname(directory);
if (parent === directory)
break;
directory = parent;
}
if (processEnvironment.HOME) {
candidates.push(path.join(processEnvironment.HOME, '.ledlightrc'));
}
return [...new Set(candidates)];
}
function resolveSetting(value, configurationPath, option) {
let setting = value.trim();
if ((setting.startsWith('"') && setting.endsWith('"')) ||
(setting.startsWith("'") && setting.endsWith("'"))) {
setting = setting.slice(1, -1);
}
if (setting.trim().length === 0) {
throw new Error(`${configurationPath} --${option} option expects a path`);
}
if (setting === '~' && processEnvironment.HOME)
return processEnvironment.HOME;
if (setting.startsWith('~/') && processEnvironment.HOME) {
return path.join(processEnvironment.HOME, setting.slice(2));
}
return path.resolve(path.dirname(configurationPath), setting);
}
function read() {
const configurationPath = configurationPaths().find((candidate) => fs.existsSync(candidate));
if (!configurationPath)
return {};
const settings = {};
const lines = fs.readFileSync(configurationPath, 'utf8')
.split(/\r?\n/u)
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith(';'));
for (const line of lines) {
const match = /^--(file|cache-home)(?:\s+|=)(.*)$/u.exec(line);
if (!match) {
throw new Error(`${configurationPath} only supports --file and --cache-home options`);
}
const option = match[1];
const value = match[2];
if (Object.hasOwn(settings, option)) {
throw new Error(`${configurationPath} may only contain one --${option} option`);
}
settings[option] = resolveSetting(value, configurationPath, option);
}
return { journalPath: settings.file, cacheHome: settings['cache-home'] };
}
return { read };
};
|