Skip to content

Commit

Permalink
Remove fs-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
1000ch committed Aug 22, 2021
1 parent bc6e05d commit 9f639d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 3 additions & 2 deletions lib/options-manager.js
@@ -1,7 +1,7 @@
import {promises as fs} from 'node:fs';
import process from 'node:process';
import os from 'node:os';
import path from 'node:path';
import fsExtra from 'fs-extra';
import arrify from 'arrify';
import {mergeWith, flow, pick} from 'lodash-es';
import pathExists from 'path-exists';
Expand Down Expand Up @@ -128,7 +128,8 @@ const mergeWithFileConfig = async options => {

options.tsConfigPath = await getTsConfigCachePath([options.filePath], options.tsConfigPath, options.cwd);
options.ts = true;
await fsExtra.outputJson(options.tsConfigPath, makeTSConfig(tsConfig, tsConfigPath, [options.filePath]));
const config = makeTSConfig(tsConfig, tsConfigPath, [options.filePath]);
await fs.writeFile(options.tsConfigPath, JSON.stringify(config));
}

return {options, prettierOptions};
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -76,7 +76,6 @@
"esm-utils": "^1.1.0",
"find-cache-dir": "^3.3.1",
"find-up": "^5.0.0",
"fs-extra": "^10.0.0",
"get-stdin": "^9.0.0",
"globby": "^12.0.0",
"imurmurhash": "^0.1.4",
Expand Down
7 changes: 3 additions & 4 deletions test/options-manager.js
@@ -1,14 +1,13 @@
import {promises as fs} from 'node:fs';
import process from 'node:process';
import path from 'node:path';
import test from 'ava';
import {omit} from 'lodash-es';
import fsExtra from 'fs-extra';
import slash from 'slash';
import createEsmUtils from 'esm-utils';
import {DEFAULT_EXTENSION, DEFAULT_IGNORES} from '../lib/constants.js';
import * as manager from '../lib/options-manager.js';

const {readJson} = fsExtra;
const {__dirname, require, json} = createEsmUtils(import.meta);
const parentConfig = json.loadSync('./fixtures/nested/package.json');
const childConfig = json.loadSync('./fixtures/nested/child/package.json');
Expand Down Expand Up @@ -557,7 +556,7 @@ test('mergeWithFileConfig: typescript files', async t => {
const expectedConfigPath = new RegExp(`${slash(cwd)}/node_modules/.cache/xo-linter/tsconfig\\..*\\.json[\\/]?$`, 'u');
t.regex(slash(options.tsConfigPath), expectedConfigPath);
t.deepEqual(omit(options, 'tsConfigPath'), expected);
t.deepEqual(await readJson(options.tsConfigPath), {
t.deepEqual(JSON.parse(await fs.readFile(options.tsConfigPath)), {
extends: path.resolve(cwd, 'tsconfig.json'),
files: [path.resolve(cwd, 'file.ts')],
include: [slash(path.resolve(cwd, '**/*.ts')), slash(path.resolve(cwd, '**/*.tsx'))],
Expand All @@ -579,7 +578,7 @@ test('mergeWithFileConfig: tsx files', async t => {
const expectedConfigPath = new RegExp(`${slash(cwd)}/node_modules/.cache/xo-linter/tsconfig\\..*\\.json[\\/]?$`, 'u');
t.regex(slash(options.tsConfigPath), expectedConfigPath);
t.deepEqual(omit(options, 'tsConfigPath'), expected);
t.deepEqual(await readJson(options.tsConfigPath), {
t.deepEqual(JSON.parse(await fs.readFile(options.tsConfigPath)), {
extends: path.resolve(cwd, 'tsconfig.json'),
files: [path.resolve(cwd, 'file.tsx')],
include: [slash(path.resolve(cwd, '**/*.ts')), slash(path.resolve(cwd, '**/*.tsx'))],
Expand Down

0 comments on commit 9f639d4

Please sign in to comment.