Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kaelzhang/nodegit-read-config

Read config for @nodegit commands
https://github.com/kaelzhang/nodegit-read-config

node-git util

Last synced: 12 days ago
JSON representation

Read config for @nodegit commands

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/kaelzhang/nodegit-read-config.svg?branch=master)](https://travis-ci.org/kaelzhang/nodegit-read-config)
[![Coverage](https://codecov.io/gh/kaelzhang/nodegit-read-config/branch/master/graph/badge.svg)](https://codecov.io/gh/kaelzhang/nodegit-read-config)

# @nodegit/read-config

Read config for @nodegit commands

## Install

```sh
$ npm i @nodegit/read-config
```

## Usage

```js
const config = require('@nodegit/read-config')
const {read, edit, path} = config('push', {
defaults: {
allowForcePush: true
}
})

console.log(await read())
```

## config(name, options)

- **name** `string` name of the config which indicates that the config file will be located at `~/.nodegit/config/${name}.js`
- **options** `Object`
- **defaults?** `Object` the default value of the configuration
- **defaultFileContent?** `string | Buffer` the default configuration content to be used if there is no config file found.

If `options.defaults` is specified, then it will ignore `options.defaultFileContent`.

```js
const {read} = config('push', {
defaultFileContent:
`module.exports = {
editor: 'vscode'
}`
})

const {editor} = await read()
```

### await read(): Object

Get the local config. If there is no config file found, it will create one.

### await edit(): void

Open the default editor and edit the config file

### getter: path

Returns `path` the absolute pathname of the config file

## License

[MIT](LICENSE)