Skip to content

Commit 6841120

Browse files
committed
fix(studio): keep the project-folder change out of the shared signature check
1 parent 64bb221 commit 6841120

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎packages/cli/src/server/studioServer.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ export function createStudioServer(options: StudioServerOptions): StudioServer {
425425
const project: ResolvedProject = { id: projectId, dir: projectDir, title: projectId };
426426
let cachedProjectSignature: string | null = null;
427427
watcher.addListener((changedPath) => {
428-
if (affectsProjectSignature(projectDir, join(projectDir, changedPath))) {
428+
if (changedPath === "." || affectsProjectSignature(projectDir, join(projectDir, changedPath))) {
429429
cachedProjectSignature = null;
430430
}
431431
});

‎packages/studio-server/src/helpers/projectSignature.test.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ describe("affectsProjectSignature", () => {
6666

6767
it("rejects a path outside the project", () => {
6868
expect(affectsProjectSignature(PROJECT, resolve("/projects/other/index.html"))).toBe(false);
69-
});
70-
71-
it("invalidates the signature when the project directory itself changes", () => {
72-
expect(affectsProjectSignature(PROJECT, PROJECT)).toBe(true);
69+
expect(affectsProjectSignature(PROJECT, PROJECT)).toBe(false);
7370
});
7471
});
7572

‎packages/studio-server/src/helpers/projectSignature.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ export const STUDIO_SIGNATURE_MANIFEST_PATHS = [
6060
*/
6161
export function affectsProjectSignature(projectDir: string, changedPath: string): boolean {
6262
const relativePath = relative(resolve(projectDir), resolve(changedPath));
63-
if (relativePath.startsWith("..") || isAbsolute(relativePath) || isAtomicTempPath(relativePath)) {
63+
if (
64+
relativePath === "" ||
65+
relativePath.startsWith("..") ||
66+
isAbsolute(relativePath) ||
67+
isAtomicTempPath(relativePath)
68+
) {
6469
return false;
6570
}
6671
const segments = relativePath.split(sep);

0 commit comments

Comments
 (0)