Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/cli.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/usr/bin/env node

import { readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

import { program } from 'commander';
import Typograf from 'typograf';

import utils from './utils.mjs';
import printError from './printError.mjs';

const __dirname = dirname(fileURLToPath(import.meta.url));
const locales = Typograf.getLocales();
const types = ['digit', 'name', 'default'];

Expand All @@ -17,7 +19,7 @@ function splitByCommas(str) {
}

program
.version(JSON.parse(readFileSync('./package.json', 'utf8')).version)
.version(JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8')).version)
.usage('[options] <file>')
.option('-l, --locale <locale>', `set the locale for rules (separated by commas). Available locales: "${locales.join('", "')}". Default: ru`, splitByCommas)
.option('-d, --disable-rule <rule>', 'disable rules (separated by commas)', splitByCommas)
Expand Down
6 changes: 4 additions & 2 deletions bin/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { readFileSync, existsSync, statSync } from 'node:fs';
import { extname } from 'node:path';
import { dirname, extname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import { program } from 'commander';

import lint from './lint.mjs';
import printError from './printError.mjs';
import Typograf from 'typograf';

const defaultConfig = JSON.parse(readFileSync('./typograf.json', 'utf8'));
const __dirname = dirname(fileURLToPath(import.meta.url));
const defaultConfig = JSON.parse(readFileSync(join(__dirname, '../typograf.json'), 'utf8'));

const DEFAULT_USER_CONFIG = '.typograf.json';

Expand Down