Vite: Fix glob path creation for Windows (#21305)

Closes #21101 

## What I did

use the slash package instead of posix path

## How to test

1. check out the repository in windows
2. run yarn task --task build --template react-vite/default-ts --start-from=install
3. it should work

-->

## Checklist

**Help**: not sure about how to test this

- [ ] Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)

#### Maintainers

- [ ] If this PR should be tested against many or all sandboxes,
      make sure to add the `ci:merged` or `ci:daily` GH label to it.
- [ ] Make sure this PR contains **one** of the labels below.

`["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]`
This commit is contained in:
Ian VanSchooten 2023-03-01 10:40:56 -05:00 committed by GitHub
commit 73f4cc74bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import * as posixPath from 'node:path/posix'; // Glob requires forward-slashes
import * as path from 'path';
import slash from 'slash';
import { promise as glob } from 'glob-promise';
import { normalizeStories } from '@storybook/core-common';
@ -11,14 +12,12 @@ export async function listStories(options: Options) {
configDir: options.configDir,
workingDir: options.configDir,
}).map(({ directory, files }) => {
const pattern = posixPath.join(directory, files);
const pattern = path.join(directory, files);
const absolutePattern = path.isAbsolute(pattern)
? pattern
: path.join(options.configDir, pattern);
return glob(
posixPath.isAbsolute(pattern) ? pattern : posixPath.join(options.configDir, pattern),
{
follow: true,
}
);
return glob(slash(absolutePattern), { follow: true });
})
)
).reduce((carry, stories) => carry.concat(stories), []);