diff --git a/package.json b/package.json index 878d004..6d524ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octomind/octomind", - "version": "3.8.0", + "version": "3.8.1", "description": "a command line client for octomind apis", "main": "./dist/index.js", "packageManager": "pnpm@10.26.0+sha512.3b3f6c725ebe712506c0ab1ad4133cf86b1f4b687effce62a9b38b4d72e3954242e643190fc51fa1642949c735f403debd44f5cb0edd657abe63a8b6a7e1e402", diff --git a/src/tools/sync/yml.ts b/src/tools/sync/yml.ts index d94e74f..f0aa73e 100644 --- a/src/tools/sync/yml.ts +++ b/src/tools/sync/yml.ts @@ -192,7 +192,7 @@ export const cleanupFilesystem = ({ newTestCases: SyncTestCase[]; destination: string | undefined; }) => { - const rootFolderPath = destination ?? "./"; + const rootFolderPath = destination ?? process.cwd(); const existingtestCases = readTestCasesFromDir(rootFolderPath); @@ -200,6 +200,12 @@ export const cleanupFilesystem = ({ existingtestCases.map((tc) => [tc.id, tc]), ); + // There is generally a bigger issue here: + // We need a better check what changed locally. + // Imagine you rename a test case remotely, and then you locally change steps in child test case. + // Then you pull, and you local changes will just be deleted. + // Same applies for changing the dependency, as it will be in a different folder. We also don't clean up these folders properly. + for (const testCase of newTestCases) { const existingTestCase = existingTestCasesById.get(testCase.id); if (existingTestCase) { @@ -211,9 +217,12 @@ export const cleanupFilesystem = ({ rootFolderPath, existingTestCasePath.replace(/\.yaml$/, ""), ); + const oldFilePath = path.join(rootFolderPath, existingTestCasePath); if (existingTestCase.description !== testCase.description) { - fs.unlinkSync(path.join(rootFolderPath, existingTestCasePath)); + if (fs.existsSync(oldFilePath)) { + fs.unlinkSync(oldFilePath); + } if (fs.existsSync(oldFolderPath)) { fs.rmSync(oldFolderPath, { recursive: true, force: true });