Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fix isGenerateStoriesFileAtBuild does not work correctly on windows #76

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading