Skip to content

Commit 23e49d4

Browse files
Default to subdirectories when saving scope facets via the recorder (#3012)
1 parent 76f5f03 commit 23e49d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/test-case-recorder/src/ScopeTestRecorder.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,17 @@ export class ScopeTestRecorder {
9090
await fsPromises.mkdir(langDirectory, { recursive: true });
9191

9292
for (const { facet, content } of facetsToAdd) {
93+
const fileName = `${facet}.scope`;
9394
const fullContent = `${content}---\n`;
94-
let filePath = path.join(langDirectory, `${facet}.scope`);
95+
const subDirectory = path.join(langDirectory, facet.split(".")[0]);
96+
const directory = fs.existsSync(subDirectory)
97+
? subDirectory
98+
: langDirectory;
99+
let filePath = path.join(directory, fileName);
95100
let i = 2;
96101

97102
while (fs.existsSync(filePath)) {
98-
filePath = path.join(langDirectory, `${facet}${i++}.scope`);
103+
filePath = path.join(directory, `${facet}${i++}.scope`);
99104
}
100105

101106
await fsPromises.writeFile(filePath, fullContent, "utf-8");

0 commit comments

Comments
 (0)