Skip to content

Commit ee7f4f3

Browse files
Merge pull request #57 from magebitcom/bugfix/56
Bugfix/56
2 parents a2cd6ad + 7ca325b commit ee7f4f3

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/command/GenerateXmlCatalogCommand.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class GenerateXmlCatalogCommand extends Command {
2929
const catalogLocation = Uri.joinPath(workspaceFolder.uri, '.vscode/magento-catalog.xml');
3030

3131
if (!(await FileSystem.fileExists(catalogLocation))) {
32-
const success = await this.generateCatalog(workspaceFolder);
32+
const success = await this.generateCatalog();
3333

3434
if (!success) {
3535
return;
@@ -39,7 +39,9 @@ export default class GenerateXmlCatalogCommand extends Command {
3939
await this.formatAndWriteCatalog(catalogLocation, workspaceFolder.uri);
4040
await this.updateXmlConfig(workspaceFolder, catalogLocation);
4141

42-
window.showInformationMessage('XML URN catalog generated and configured successfully');
42+
window.showInformationMessage(
43+
'XML URN catalog generated and configured successfully. You might need to reload the editor for changes to take effect.'
44+
);
4345
}
4446

4547
private async formatAndWriteCatalog(catalogLocation: Uri, workspaceUri: Uri) {
@@ -83,24 +85,24 @@ export default class GenerateXmlCatalogCommand extends Command {
8385
await FileSystem.writeFile(catalogLocation, formattedCatalog);
8486
}
8587

86-
private async generateCatalog(workspaceFolder: WorkspaceFolder): Promise<boolean> {
87-
const catalogLocation = Uri.joinPath(workspaceFolder.uri, '.vscode/magento-catalog.xml');
88-
88+
private async generateCatalog(): Promise<boolean> {
8989
const magentoCli = new MagentoCli();
9090

9191
try {
92-
await magentoCli.run('dev:urn-catalog:generate', [catalogLocation.fsPath]);
92+
await magentoCli.run('dev:urn-catalog:generate', ['.vscode/magento-catalog.xml']);
9393
} catch (error) {
9494
console.error(error);
9595

9696
window.showErrorMessage(
9797
'Failed to generate URN catalog. Try running this command manually: \n\n' +
98-
`bin/magento dev:urn-catalog:generate ${catalogLocation.fsPath}`
98+
`bin/magento dev:urn-catalog:generate .vscode/magento-catalog.xml`
9999
);
100100

101101
return false;
102102
}
103103

104+
magentoCli.dispose();
105+
104106
return true;
105107
}
106108

src/common/MagentoCli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export default class MagentoCli {
3636
});
3737
}
3838

39+
public dispose() {
40+
const terminal = vscode.window.terminals.find(t => t.name === MagentoCli.TERMINAL_NAME);
41+
42+
if (terminal) {
43+
terminal.dispose();
44+
}
45+
}
46+
3947
private getOrCreateTerminal(): vscode.Terminal {
4048
const terminal = vscode.window.terminals.find(t => t.name === MagentoCli.TERMINAL_NAME);
4149

0 commit comments

Comments
 (0)