fix: compatibility of fs-extra with esm (#4017)

This commit is contained in:
Vben
2024-08-03 09:49:46 +08:00
committed by GitHub
parent bf8a5ffb5d
commit 27ffc9e71b
11 changed files with 78 additions and 33 deletions

View File

@@ -6,9 +6,9 @@ import {
colors,
consola,
findMonorepoRoot,
fs,
getPackages,
gitAdd,
outputJSON,
prettierFormat,
toPosixPath,
} from '@vben/node-utils';
@@ -38,7 +38,7 @@ async function createCodeWorkspace({
const monorepoRoot = findMonorepoRoot();
const outputPath = join(monorepoRoot, CODE_WORKSPACE_FILE);
await fs.outputJSON(outputPath, { folders }, { encoding: 'utf8', spaces });
await outputJSON(outputPath, { folders }, spaces);
await prettierFormat(outputPath);
if (autoCommit) {

View File

@@ -6,10 +6,12 @@ import { basename, dirname, join } from 'node:path';
import {
colors,
consola,
ensureFile,
findMonorepoRoot,
fs,
generatorContentHash,
getPackages,
outputJSON,
readJSON,
UNICODE,
} from '@vben/node-utils';
@@ -56,8 +58,8 @@ function getCacheFile() {
async function readCache(cacheFile: string) {
try {
await fs.ensureFile(cacheFile);
return await fs.readJSON(cacheFile, { encoding: 'utf8' });
await ensureFile(cacheFile);
return await readJSON(cacheFile);
} catch {
return {};
}
@@ -73,7 +75,7 @@ async function runPublint(files: string[], { check }: PubLintCommandOptions) {
const results = await Promise.all(
lintFiles.map(async (file) => {
try {
const pkgJson = await fs.readJSON(file);
const pkgJson = await readJSON(file);
if (pkgJson.private) {
return null;
@@ -106,7 +108,7 @@ async function runPublint(files: string[], { check }: PubLintCommandOptions) {
}),
);
await fs.outputJSON(cacheFile, cache);
await outputJSON(cacheFile, cache);
printResult(results, check);
}