fix(cli): create empty plugin directory

This commit is contained in:
Alex Yang
2023-07-27 07:02:06 -07:00
parent 59f53760d1
commit 3a64b43032

View File

@@ -1,5 +1,6 @@
import { ok } from 'node:assert';
import { open, readFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { mkdir, open, readFile } from 'node:fs/promises';
import path from 'node:path';
import { parseArgs } from 'node:util';
@@ -95,14 +96,9 @@ const metadata: Metadata = {
assets: new Set(),
};
const coreOutDir = path.resolve(
projectRoot,
'apps',
'core',
'public',
'plugins',
plugin
);
const outDir = path.resolve(projectRoot, 'apps', 'core', 'public', 'plugins');
const coreOutDir = path.resolve(outDir, plugin);
const serverOutDir = path.resolve(
projectRoot,
@@ -113,7 +109,7 @@ const serverOutDir = path.resolve(
plugin
);
const pluginListJsonPath = path.resolve(coreOutDir, '..', 'plugin-list.json');
const pluginListJsonPath = path.resolve(outDir, 'plugin-list.json');
const coreEntry = path.resolve(pluginDir, json.affinePlugin.entry.core);
if (json.affinePlugin.entry.server) {
@@ -168,7 +164,10 @@ await build({
{
name: 'generate-list-json',
async generateBundle() {
const file = await open(pluginListJsonPath, 'as+');
if (!existsSync(outDir)) {
await mkdir(outDir, { recursive: true });
}
const file = await open(pluginListJsonPath, 'w+', 0o777);
const txt = await file.readFile({
encoding: 'utf-8',
});