How to use the @fimbul/ymir.ConfigurationError function in @fimbul/ymir

To help you get started, we’ve selected a few @fimbul/ymir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fimbullinter / wotan / packages / wotan / src / runner.ts View on Github external
nodir: true,
        realpathCache: {},
        statCache: {},
        symlinks: {},
    };
    for (const pattern of patterns) {
        let matched = pattern.hasMagic;
        for (const normalized of pattern.normalized) {
            const match = glob.sync(normalized, globOptions);
            if (match.length !== 0) {
                matched = true;
                result.push(...match);
            }
        }
        if (!matched && !isExcluded(pattern.normalized[0], exclude.map((p) => new Minimatch(p, {dot: true}))))
            throw new ConfigurationError(`'${pattern.normalized[0]}' does not exist.`);
    }
    return new Set(result.map(unixifyPath)); // deduplicate files
}
github fimbullinter / wotan / packages / wotan / src / services / formatter-loader.ts View on Github external
public loadFormatter(name: string): FormatterConstructor {
        let formatter: FormatterConstructor | undefined;
        if (/^[a-zA-Z-]+$/.test(name))
            formatter = this.host.loadCoreFormatter(name);
        if (formatter === undefined)
            formatter = this.host.loadCustomFormatter(name, this.directories.getCurrentDirectory());
        if (formatter === undefined)
            throw new ConfigurationError(`Cannot find formatter '${name}' relative to '${this.directories.getCurrentDirectory()}'.`);
        return formatter;
    }
}
github fimbullinter / wotan / packages / wotan / src / services / configuration-manager.ts View on Github external
public resolve(name: string, basedir: string): string {
        try {
            return this.configProvider.resolve(name, path.resolve(this.directories.getCurrentDirectory(), basedir));
        } catch (e) {
            throw new ConfigurationError(`${e && e.message}`);
        }
    }
github fimbullinter / wotan / packages / wotan / src / services / configuration-manager.ts View on Github external
const loadResolved = (file: string): Configuration => {
            const circular = stack.includes(file);
            stack.push(file);
            if (circular)
                throw new Error(`Circular configuration dependency.`);
            const config = this.configProvider.load(file, {
                stack,
                load: (name) => resolveCachedResult(this.configCache, this.configProvider.resolve(name, path.dirname(file)), loadResolved),
            });
            stack.pop();
            return config;
        };
        try {
            return resolveCachedResult(this.configCache, path.resolve(this.directories.getCurrentDirectory(), fileName), loadResolved);
        } catch (e) {
            throw new ConfigurationError(`Error loading ${stack.join(' => ')}: ${e && e.message}`);
        }
    }
}
github fimbullinter / wotan / packages / wotan / src / runner.ts View on Github external
private checkConfigDirectory(fileOrDirName: string): string {
        switch (this.fs.getKind(fileOrDirName)) {
            case FileKind.NonExistent:
                throw new ConfigurationError(`The specified path does not exist: '${fileOrDirName}'`);
            case FileKind.Directory: {
                const file = unixifyPath(path.join(fileOrDirName, 'tsconfig.json'));
                if (!this.fs.isFile(file))
                    throw new ConfigurationError(`Cannot find a tsconfig.json file at the specified directory: '${fileOrDirName}'`);
                return file;
            }
            default:
                return fileOrDirName;
        }
    }
github fimbullinter / wotan / packages / wotan / src / services / configuration-manager.ts View on Github external
public findPath(file: string): string | undefined {
        file = path.resolve(this.directories.getCurrentDirectory(), file);
        try {
            return this.configProvider.find(file);
        } catch (e) {
            throw new ConfigurationError(`Error finding configuration for '${file}': ${e && e.message}`);
        }
    }
github fimbullinter / wotan / packages / wotan / src / runner.ts View on Github external
private* getFilesAndProgram(
        projects: ReadonlyArray,
        patterns: ReadonlyArray,
        exclude: ReadonlyArray,
        host: ProjectHost,
        references: boolean,
    ): Iterable<{files: Iterable, program: ts.Program}> {
        const cwd = unixifyPath(this.directories.getCurrentDirectory());
        if (projects.length !== 0) {
            projects = projects.map((configFile) => this.checkConfigDirectory(unixifyPath(path.resolve(cwd, configFile))));
        } else if (references) {
            projects = [this.checkConfigDirectory(cwd)];
        } else {
            const project = ts.findConfigFile(cwd, (f) => this.fs.isFile(f));
            if (project === undefined)
                throw new ConfigurationError(`Cannot find tsconfig.json for directory '${cwd}'.`);
            projects = [project];
        }

        const allMatchedFiles: string [] = [];
        const include: IMinimatch[] = [];
        const nonMagicGlobs: NonMagicGlob[] = [];
        for (const pattern of patterns) {
            if (!pattern.hasMagic) {
                const mm = new Minimatch(pattern.normalized[0]);
                nonMagicGlobs.push({raw: pattern.normalized[0], match: mm});
                include.push(mm);
            } else {
                include.push(...pattern.normalized.map((p) => new Minimatch(p)));
            }
        }
        const ex = exclude.map((p) => new Minimatch(p, {dot: true}));