-
Notifications
You must be signed in to change notification settings - Fork 90
fix(astro): sub folders not working on Windows #225
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
42990d1
ci: allow manual runs for tests
AriPerkkio 110d4ce
refactor: move `getFilesRefList` to its own file
AriPerkkio 4f6d6f6
test: add failing test case for #209
AriPerkkio 7581c15
fix(astro): convert windows filepaths to webcontainer compatible
AriPerkkio e44d4c8
test: add test case for file ref JSON contents
AriPerkkio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ on: | |
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/astro/src/default/utils/content/files-ref.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect, test } from 'vitest'; | ||
|
||
import { getFilesRefList } from './files-ref'; | ||
|
||
test('getFilesRefList returns files', async () => { | ||
const files = await getFilesRefList('test/fixtures/files', ''); | ||
|
||
expect(files).toMatchInlineSnapshot(` | ||
[ | ||
"test-fixtures-files.json", | ||
[ | ||
"/first.js", | ||
"/nested/directory/second.ts", | ||
], | ||
] | ||
`); | ||
}); | ||
Comment on lines
+5
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Failure on Windows CI before fix:
https://github.com/stackblitz/tutorialkit/actions/runs/10287876681/job/28471979082?pr=225 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { FilesRefList } from '@tutorialkit/types'; | ||
import { folderPathToFilesRef } from '@tutorialkit/types'; | ||
import glob from 'fast-glob'; | ||
import path from 'node:path'; | ||
import { IGNORED_FILES } from '../constants'; | ||
|
||
const CONTENT_DIR = path.join(process.cwd(), 'src/content/tutorial'); | ||
|
||
export async function getFilesRefList(pathToFolder: string, base = CONTENT_DIR): Promise<FilesRefList> { | ||
const root = path.join(base, pathToFolder); | ||
|
||
const filePaths = ( | ||
await glob(`${glob.convertPathToPattern(root)}/**/*`, { | ||
onlyFiles: true, | ||
ignore: IGNORED_FILES, | ||
dot: true, | ||
}) | ||
).map((filePath) => `/${path.relative(root, filePath).replaceAll(path.sep, '/')}`); | ||
|
||
filePaths.sort(); | ||
|
||
const filesRef = folderPathToFilesRef(pathToFolder); | ||
|
||
return [filesRef, filePaths]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'Example JS file'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'Example TS file'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is useful for contributors. It allows them (and me) to run CI manually on specific branch on forks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's a really nice addition! 😃