Skip to content

Commit

Permalink
Revert "Remove fs-extra dependency (xojs#597)"
Browse files Browse the repository at this point in the history
This reverts commit 098a594.
  • Loading branch information
devinrhode2 committed Oct 15, 2021
1 parent eefd88a commit 675c7ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/options-manager.js
@@ -1,7 +1,8 @@
import {existsSync, promises as fs} from 'node:fs';
import {existsSync} 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 {findUpSync} from 'find-up';
Expand Down Expand Up @@ -127,9 +128,7 @@ const mergeWithFileConfig = async options => {

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

return {options, prettierOptions};
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -75,6 +75,7 @@
"esm-utils": "^2.0.0",
"find-cache-dir": "^3.3.2",
"find-up": "^6.1.0",
"fs-extra": "^10.0.0",
"get-stdin": "^9.0.0",
"globby": "^12.0.2",
"imurmurhash": "^0.1.4",
Expand Down
7 changes: 4 additions & 3 deletions test/options-manager.js
@@ -1,13 +1,14 @@
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 +558,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(JSON.parse(await fs.readFile(options.tsConfigPath)), {
t.deepEqual(await readJson(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 +580,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(JSON.parse(await fs.readFile(options.tsConfigPath)), {
t.deepEqual(await readJson(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 675c7ba

Please sign in to comment.