1
0
Fork 0

lint: remove confusing *sync wrapper names

This commit is contained in:
ssube 2019-11-02 07:35:20 -05:00 committed by Sean Sube
parent b3dc864f0d
commit 4159004dd4
5 changed files with 12 additions and 12 deletions

View File

@ -84,8 +84,8 @@ const bundle = {
'node_modules/noicejs/out/main-bundle.js': [
'BaseError',
'ConsoleLogger',
'logWithLevel',
'NullLogger',
'logWithLevel',
],
'node_modules/js-yaml/index.js': [
'DEFAULT_SAFE_SCHEMA',

View File

@ -5,7 +5,7 @@ import { join } from 'path';
import { NotFoundError } from '../error/NotFoundError';
import { YamlParser } from '../parser/YamlParser';
import { readFileSync } from '../source';
import { readFile } from '../source';
import { CONFIG_ENV, CONFIG_SCHEMA } from './schema';
import { includeSchema } from './type/Include';
@ -70,7 +70,7 @@ export async function readConfig(path: string): Promise<string | undefined> {
try {
// need to await this read to catch the error, need to catch the error to check the code
// tslint:disable-next-line:prefer-immediate-return
const data = await readFileSync(path, {
const data = await readFile(path, {
encoding: 'utf-8',
});
return data;

View File

@ -67,7 +67,7 @@ export class SchemaRule implements RuleData, Visitor<RuleResult> {
if (filter(node)) {
ctx.logger.debug({ item: node }, 'checking item');
if (!check(node) && !isNil(check.errors) && check.errors.length > 0) {
if (!check(node) && hasItems(check.errors)) {
ctx.error(...Array.from(check.errors).map(friendlyError));
}
} else {

View File

@ -2,7 +2,7 @@ import { Dictionary, intersection, isNil } from 'lodash';
import { LogLevel } from 'noicejs';
import { YamlParser } from '../parser/YamlParser';
import { readFileSync } from '../source';
import { readFile } from '../source';
import { ensureArray } from '../utils';
import { VisitorContext } from '../visitor/VisitorContext';
import { SchemaRule } from './SchemaRule';
@ -52,7 +52,7 @@ export async function loadRules(paths: Array<string>, ctx: VisitorContext): Prom
const rules = [];
for (const path of paths) {
const contents = await readFileSync(path, {
const contents = await readFile(path, {
encoding: 'utf-8',
});

View File

@ -1,18 +1,18 @@
import { readFile, writeFile } from 'fs';
import { readFile as readBack, writeFile as writeBack } from 'fs';
import { isNil } from 'lodash';
import { promisify } from 'util';
export const FILE_ENCODING = 'utf-8';
export const readFileSync = promisify(readFile);
export const writeFileSync = promisify(writeFile);
export const readFile = promisify(readBack);
export const writeFile = promisify(writeBack);
export async function loadSource(path: string): Promise<string> {
if (path === '-') {
return readFileSync(0, {
return readFile(0, {
encoding: FILE_ENCODING,
});
} else {
return readFileSync(path, {
return readFile(path, {
encoding: FILE_ENCODING,
});
}
@ -30,7 +30,7 @@ export async function writeSource(path: string, data: string): Promise<void> {
});
});
} else {
return writeFileSync(path, data, {
return writeFile(path, data, {
encoding: FILE_ENCODING,
});
}