From 2dae4d0f109e2c4b89a75b051afff77bc4151d2b Mon Sep 17 00:00:00 2001 From: takuma-ru Date: Sun, 14 Apr 2024 23:25:55 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20`isGenerateStoriesFileAtBu?= =?UTF-8?q?ild`=20does=20not=20work=20correctly=20on=20windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asg.code-workspace | 9 +++++++++ packages/auto-story-generator/src/core/genStoryFile.ts | 2 ++ packages/auto-story-generator/src/index.ts | 10 ++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/asg.code-workspace b/asg.code-workspace index 358c1f4..ad2ff32 100644 --- a/asg.code-workspace +++ b/asg.code-workspace @@ -46,6 +46,15 @@ "vitepress", "vumdoc", ], + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.tabSize": 2, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.addMissingImports": "explicit", + }, + "files.eol": "\n", + "typescript.preferences.importModuleSpecifier": "non-relative", }, "extensions": {}, } diff --git a/packages/auto-story-generator/src/core/genStoryFile.ts b/packages/auto-story-generator/src/core/genStoryFile.ts index ccbb0d7..7519627 100644 --- a/packages/auto-story-generator/src/core/genStoryFile.ts +++ b/packages/auto-story-generator/src/core/genStoryFile.ts @@ -51,6 +51,8 @@ export const genStoryFile = async ({ }; const isGenFile = hasGenFile(); + consola.info(`isGenFile: ${isGenFile}`); + if (!isGenFile) return; const { diff --git a/packages/auto-story-generator/src/index.ts b/packages/auto-story-generator/src/index.ts index 6937d3a..60d26eb 100644 --- a/packages/auto-story-generator/src/index.ts +++ b/packages/auto-story-generator/src/index.ts @@ -1,7 +1,7 @@ import path from "path"; import { consola } from "consola"; -import { sync } from "glob"; +import { globSync } from "glob"; import { from, mergeMap } from "rxjs"; import { createUnplugin } from "unplugin"; @@ -16,7 +16,7 @@ let isExecuted: boolean = false; const unplugin = createUnplugin((options: Options, meta) => { consola.info("ASG is running in", meta.framework); - const projectRootDir = process.cwd(); + const projectRootDir = process.cwd().replace(/\\/g, "/"); return { name: PLUGIN_NAME, @@ -29,14 +29,16 @@ const unplugin = createUnplugin((options: Options, meta) => { return; } - const allFiles = sync(path.join(process.cwd(), "**")); + const allFiles = globSync( + path.join(process.cwd(), "**").replace(/\\/g, "/"), + ); from(allFiles) .pipe( mergeMap(async (filePath) => { await genStoryFile({ options, - id: filePath, + id: filePath.replace(/\\/g, "/"), projectRootDir, }); }),