Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/command/GenerateXmlCatalogCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class GenerateXmlCatalogCommand extends Command {
const catalogLocation = Uri.joinPath(workspaceFolder.uri, '.vscode/magento-catalog.xml');

if (!(await FileSystem.fileExists(catalogLocation))) {
const success = await this.generateCatalog(workspaceFolder);
const success = await this.generateCatalog();

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

window.showInformationMessage('XML URN catalog generated and configured successfully');
window.showInformationMessage(
'XML URN catalog generated and configured successfully. You might need to reload the editor for changes to take effect.'
);
}

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

private async generateCatalog(workspaceFolder: WorkspaceFolder): Promise<boolean> {
const catalogLocation = Uri.joinPath(workspaceFolder.uri, '.vscode/magento-catalog.xml');

private async generateCatalog(): Promise<boolean> {
const magentoCli = new MagentoCli();

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

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

return false;
}

magentoCli.dispose();

return true;
}

Expand Down
8 changes: 8 additions & 0 deletions src/common/MagentoCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export default class MagentoCli {
});
}

public dispose() {
const terminal = vscode.window.terminals.find(t => t.name === MagentoCli.TERMINAL_NAME);

if (terminal) {
terminal.dispose();
}
}

private getOrCreateTerminal(): vscode.Terminal {
const terminal = vscode.window.terminals.find(t => t.name === MagentoCli.TERMINAL_NAME);

Expand Down