Remove directory from workspace by index
We were initially always removing the last folder in the workspace as we assumed that would be the directory we use. Now that we've switched to using a temporary directory, this is no longer the case so we need to find the index of the directory in the list of workspace folders and then use that index to remove the directory.
This commit is contained in:
@@ -44,8 +44,14 @@ describe("QlPackGenerator", () => {
|
||||
try {
|
||||
dir.removeCallback();
|
||||
|
||||
const end = (workspace.workspaceFolders || []).length;
|
||||
workspace.updateWorkspaceFolders(end - 1, 1);
|
||||
const workspaceFolders = workspace.workspaceFolders || [];
|
||||
const folderIndex = workspaceFolders.findIndex(
|
||||
(workspaceFolder) => workspaceFolder.name === dir.name,
|
||||
);
|
||||
|
||||
if (folderIndex !== undefined) {
|
||||
workspace.updateWorkspaceFolders(folderIndex, 1);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`Could not remove folder from workspace: ${getErrorMessage(e)}`,
|
||||
@@ -63,7 +69,6 @@ describe("QlPackGenerator", () => {
|
||||
expect(isFolderAlreadyInWorkspace(packFolderName)).toBe(true);
|
||||
expect(existsSync(qlPackYamlFilePath)).toBe(true);
|
||||
expect(existsSync(exampleQlFilePath)).toBe(true);
|
||||
|
||||
expect(packAddSpy).toHaveBeenCalledWith(packFolderPath, language);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user