Skip to content

Commit a906b24

Browse files
authored
Merge branch 'main' into joan/bump-version
2 parents eb9b374 + 186e2db commit a906b24

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

packages/astro/src/webcontainer-files.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { withResolvers } from './utils.js';
1212

1313
const FILES_FOLDER_NAME = '_files';
1414
const SOLUTION_FOLDER_NAME = '_solution';
15+
const IGNORED_FILES = ['**/.DS_Store', '**/*.swp'];
1516

1617
export class WebContainerFiles {
1718
private _watcher: FSWatcher | undefined;
@@ -20,11 +21,16 @@ export class WebContainerFiles {
2021
const { contentDir, templatesDir } = this._folders(projectRoot);
2122
const cache = new FileMapCache(logger, server, { contentDir, templatesDir });
2223

23-
this._watcher = watch([
24-
path.join(contentDir, `**/${FILES_FOLDER_NAME}/**/*`),
25-
path.join(contentDir, `**/${SOLUTION_FOLDER_NAME}/**/*`),
26-
templatesDir,
27-
]);
24+
this._watcher = watch(
25+
[
26+
path.join(contentDir, `**/${FILES_FOLDER_NAME}/**/*`),
27+
path.join(contentDir, `**/${SOLUTION_FOLDER_NAME}/**/*`),
28+
templatesDir,
29+
],
30+
{
31+
ignored: IGNORED_FILES,
32+
},
33+
);
2834

2935
this._watcher.on('all', (eventName, filePath) => {
3036
// new directories don't affect the file tree
@@ -63,7 +69,7 @@ export class WebContainerFiles {
6369
`${glob.convertPathToPattern(contentDir)}/**/${SOLUTION_FOLDER_NAME}`,
6470
`${glob.convertPathToPattern(templatesDir)}/*`,
6571
],
66-
{ onlyDirectories: true },
72+
{ onlyDirectories: true, ignore: IGNORED_FILES },
6773
);
6874

6975
await Promise.all(
@@ -209,6 +215,7 @@ class FileMapCache {
209215
async function createFileMap(dir: string) {
210216
const filePaths = await glob(`${glob.convertPathToPattern(dir)}/**/*`, {
211217
onlyFiles: true,
218+
ignore: IGNORED_FILES,
212219
});
213220

214221
// files are assumed to be sorted so that FileTree can skip some logic at runtime

0 commit comments

Comments
 (0)