facebook / facebook/jscodeshift

Add support for config files

Offen
#4 8 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
improvement
Vorherrschende Sprache
JavaScript
Sterne
10k
Forks
498
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Proposal
### Teach the binary to accept a `--config` option

This option would allow you to specify a config file on disk from which additional options would be read. The file would contain additional options to be included with the invocation; for example:

```
--cpus 2 -v
```

Options explicitly provided on the command-line would override options read from the config file. For example, given the config above, `--cpus` would be set to `4` for an invocation like this:

```
jscodeshift --config my-config --cpus 4 target.js
```
### In the absence of a `--config` option, look for config in default locations

Default locations could be:
- `.jscodeshiftrc` in current directory
- `$HOME/.jscodeshiftrc`
- `/etc/jscodeshiftrc` (or something like that)

This would, for example, enable you to provide a consistent set of Recast `printOptions` that you would use, by convention, in all of your transform scripts (ie. in the call to `toSource()`).
### Considerations

Do we want the config file to be just a dumb string that we split and pass into nomnom as though the args were passed on the commandline? Or do we prefer a more structured format (like JSON) which would allow us to pass richer configuration objects rather than just scalar values (strings, numbers, bools)? I'm inclined to think the latter, so that we could configure things like `printOptions` for Recast with:

```
{
'cpus': 2,
'v': true,
'printOptions': {'quote': 'single'}
}
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.