Function: writeCommand()
writeCommand(
directory): (command,options) =>Promise<void>
Defined in: commands.ts:121
Write a command to EventCatalog.
You can optionally override the path of the command.
Parameters
| Parameter | Type |
|---|---|
directory | string |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
command | Command |
options | { format: "md" | "mdx"; override: boolean; path: string; versionExistingContent: boolean; } |
options.format? | "md" | "mdx" |
options.override? | boolean |
options.path? | string |
options.versionExistingContent? | boolean |
Returns
Promise<void>
Example
import utils from '@eventcatalog/utils';
const { writeCommand } = utils('/path/to/eventcatalog');
// Write a command to the catalog
// Command would be written to commands/UpdateInventory
await writeCommand({
id: 'UpdateInventory',
name: 'Update Inventory',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
});
// Write a command to the catalog but override the path
// Command would be written to commands/Inventory/UpdateInventory
await writeCommand({
id: 'UpdateInventory',
name: 'Update Inventory',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { path: "/Inventory/UpdateInventory"});
// Write a command to the catalog and override the existing content (if there is any)
await writeCommand({
id: 'UpdateInventory',
name: 'Update Inventory',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { override: true });
// Write a command to the catalog and version the previous version
// only works if the new version is greater than the previous version
await writeCommand({
id: 'UpdateInventory',
name: 'Update Inventory',
version: '0.0.1',
summary: 'This is a summary',
markdown: '# Hello world',
}, { versionExistingContent: true });