Remove fs-extra from lib/cli/scripts

This commit is contained in:
ziebam 2024-09-16 22:10:51 +02:00
parent f0593f9e9e
commit ea609bfdad
2 changed files with 15 additions and 6 deletions

View File

@ -1,7 +1,6 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { readJSON } from 'fs-extra';
import { sortPackageJson } from '../../../../scripts/node_modules/sort-package-json';
import { generateMapperContent, mapCoreExportToSelf, write } from './utils';
@ -22,8 +21,12 @@ import { generateMapperContent, mapCoreExportToSelf, write } from './utils';
* remove those manually here.
*/
async function run() {
const selfPackageJson = await readJSON(join(__dirname, '../package.json'));
const corePackageJson = await readJSON(join(__dirname, '../../../core/package.json'));
const selfPackageJson = JSON.parse(
await readFile(join(__dirname, '../package.json'), { encoding: 'utf8' })
);
const corePackageJson = await JSON.parse(
await readFile(join(__dirname, '../../../core/package.json'), { encoding: 'utf8' })
);
await Promise.all(
Object.entries<Record<string, string>>(corePackageJson.exports)

View File

@ -1,8 +1,14 @@
import { ensureFile, writeFile } from 'fs-extra';
import { existsSync } from 'node:fs';
import { mkdir, writeFile } from 'node:fs/promises';
import { dirname } from 'node:path';
import { dedent } from 'ts-dedent';
export const write = async (location: string, data: string) => {
await ensureFile(location);
if (!existsSync(location)) {
const directory = dirname(location);
await mkdir(directory, { recursive: true });
}
return writeFile(location, data);
};