Skip to content

Commit

Permalink
馃悰 Fix isGenerateStoriesFileAtBuild does not work correctly on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
takuma-ru committed Apr 14, 2024
1 parent 03eaeb5 commit 2dae4d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 9 additions & 0 deletions asg.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
}
2 changes: 2 additions & 0 deletions packages/auto-story-generator/src/core/genStoryFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const genStoryFile = async ({
};
const isGenFile = hasGenFile();

consola.info(`isGenFile: ${isGenFile}`);

if (!isGenFile) return;

const {
Expand Down
10 changes: 6 additions & 4 deletions packages/auto-story-generator/src/index.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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,
Expand All @@ -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,
});
}),
Expand Down

0 comments on commit 2dae4d0

Please sign in to comment.