Copy as Markdown[View as Markdown](/docs/sdk/functions/addFileToCommand.md)

***

# Function: addFileToCommand()

> **addFileToCommand**(`directory`): (`id`, `file`, `version`?, `options`?) => `Promise`<`void`>

Defined in: commands.ts:257

Add a file to a command by it's id.

Optionally specify a version to add a file to a specific version of the command.

## Parameters[​](#parameters "Direct link to Parameters")

| Parameter   | Type     |
| ----------- | -------- |
| `directory` | `string` |

## Returns[​](#returns "Direct link to Returns")

`Function`

### Parameters[​](#parameters-1 "Direct link to Parameters")

| Parameter        | Type                                           |
| ---------------- | ---------------------------------------------- |
| `id`             | `string`                                       |
| `file`           | { `content`: `string`; `fileName`: `string`; } |
| `file.content`   | `string`                                       |
| `file.fileName`? | `string`                                       |
| `version`?       | `string`                                       |
| `options`?       | { `path`: `string`; }                          |
| `options.path`?  | `string`                                       |

### Returns[​](#returns-1 "Direct link to Returns")

`Promise`<`void`>

## Example[​](#example "Direct link to Example")

```
import utils from '@eventcatalog/utils';

const { addFileToCommand } = utils('/path/to/eventcatalog');

// adds a file to the latest UpdateInventory command
await addFileToCommand('UpdateInventory', { content: 'Hello world', fileName: 'hello.txt' });

// adds a file to a specific version of the UpdateInventory command
await addFileToCommand('UpdateInventory', { content: 'Hello world', fileName: 'hello.txt' }, '0.0.1');
```
