Skip to content

Commit

Permalink
Set default options (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv authored Jun 8, 2022
1 parent ad7c2ae commit bb380e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
22 changes: 14 additions & 8 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@

`backport` can be imported as a Node module and interacted with programatically. This can be useful when creating automation around the Backport tool. See for example the [Backport Github Action](https://github.com/sqren/backport-github-action)

### `backportRun`
### `backportRun(options, processArgs, exitCodeOnFailure)`

Backport a commit programatically. Commits can be selected via `pullNumber` or `sha`.

#### Arguments:

All of the options listed on [config-file-options.md](/docs/config-file-options.md) are valid. The most common options are:

`accessToken` _string_ **(Required)**<br/>
`options.accessToken` _string_ **(Required)**<br/>
Github access token to authenticate the request

`repoName` _string_ **(Required)**<br/>
`options.repoName` _string_ **(Required)**<br/>
Name of repository

`repoOwner` _string_ **(Required)**<br/>
`options.repoOwner` _string_ **(Required)**<br/>
Owner of repository (organisation or username)

`pullNumber` _number_<br/>
`options.pullNumber` _number_<br/>
Filter commits by pull request number

`sha` _string_<br/>
`options.sha` _string_<br/>
Filter commits by commit sha

`interactive` _boolean_<br/>
Enable interactive prompts
`options.interactive` _boolean_<br/>
Enable interactive prompts. Default: `true`

`processArgs` _array_<br/>
Useful for forwarding arguments to backport: `const processArgs = process.argv.slice(2);`

`exitCodeOnFailure` _boolean_<br/>
If `true` sets a non-zero exit code on failure. Default: `true`

#### Example

Expand Down
4 changes: 2 additions & 2 deletions src/entrypoint.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export { fetchRemoteProjectConfig as getRemoteProjectConfig } from './lib/github
export { getGlobalConfig as getLocalGlobalConfig } from './options/config/globalConfig';

export function backportRun({
options,
options = {},
processArgs = [],
exitCodeOnFailure = true,
}: {
options: ConfigFileOptions;
options?: ConfigFileOptions;

// cli args will not automatically be forwarded when backport is consumed as a module
// It is simple to forward args manually via `process.argv`:
Expand Down

0 comments on commit bb380e3

Please sign in to comment.