How to use the @fimbul/ymir.Format.Yaml 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 / utils.ts View on Github external
export function format(value: T, fmt = Format.Yaml): string {
    value = convertToPrintable(value) || {};
    switch (fmt) {
        case Format.Json:
            return JSON.stringify(value, undefined, 2);
        case Format.Json5:
            return json5.stringify(value, undefined, 2);
        case Format.Yaml:
            return yaml.safeDump(value, {
                indent: 2,
                schema: yaml.JSON_SCHEMA,
                sortKeys: true,
            });
        default:
            return assertNever(fmt);
    }
}
github fimbullinter / wotan / packages / wotan / src / utils.ts View on Github external
export function format(value: T, fmt = Format.Yaml): string {
    value = convertToPrintable(value) || {};
    switch (fmt) {
        case Format.Json:
            return JSON.stringify(value, undefined, 2);
        case Format.Json5:
            return json5.stringify(value, undefined, 2);
        case Format.Yaml:
            return yaml.safeDump(value, {
                indent: 2,
                schema: yaml.JSON_SCHEMA,
                sortKeys: true,
            });
        default:
            return assertNever(fmt);
    }
}
github fimbullinter / wotan / packages / wotan / src / commands / save.ts View on Github external
public run({command: _command, ...config}: LintCommand) {
        const newContent = format>(
            {
                ...this.options,
                ...config,
                fix: config.fix || undefined,
                reportUselessDirectives: config.reportUselessDirectives || undefined,
                references: config.references || undefined,
            },
            Format.Yaml,
        );
        const filePath = path.join(this.directories.getCurrentDirectory(), '.fimbullinter.yaml');
        if (newContent.trim() === '{}') {
            try {
                this.fs.remove(filePath);
                this.logger.log("Removed '.fimbullinter.yaml'.");
            } catch {}
        } else {
            this.fs.writeFile(filePath, newContent);
            this.logger.log("Updated '.fimbullinter.yaml'.");
        }
        return true;
    }
}