# Code

Represents the contents to initialize the repository with.

- Source: [`aws-codecommit/lib/code.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-codecommit/lib/code.ts#L22)
- Type last changed: v2.4.0 · 6 Jan 2022

## Example

```ts
const repo = new codecommit.Repository(this, 'Repository', {
  repositoryName: 'MyRepositoryName',
  code: codecommit.Code.fromDirectory(path.join(__dirname, 'directory/'), 'develop'), // optional property, branch parameter can be omitted
});
```

## Initializer

```ts
new Code()
```

## Methods

- `bind(scope: Construct): CodeConfig` — This method is called after a repository is passed this instance of Code in its 'code' property.

  **Parameters**

  - `scope` — the binding scope.

- `fromAsset(asset: Asset, branch?: string): Code // chainable` (static) — Code from user-supplied asset.

  **Parameters**

  - `asset` — pre-existing asset.
  - `branch` — the name of the branch to create in the repository.

- `fromDirectory(directoryPath: string, branch?: string): Code // chainable` (static) — Code from directory.

  **Parameters**

  - `directoryPath` — the path to the local directory containing the contents to initialize the repository with.
  - `branch` — the name of the branch to create in the repository.

- `fromZipFile(filePath: string, branch?: string): Code // chainable` (static) — Code from preexisting ZIP file.

  **Parameters**

  - `filePath` — the path to the local ZIP file containing the contents to initialize the repository with.
  - `branch` — the name of the branch to create in the repository.
