Skip to content

Commit

Permalink
Merge d538180 into 0a60527
Browse files Browse the repository at this point in the history
  • Loading branch information
sveyret committed Feb 28, 2020
2 parents 0a60527 + d538180 commit 7ffc5b1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 24 deletions.
10 changes: 4 additions & 6 deletions doc/en/devmanual.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ By default, when _confinode_ is searching for a configuration file for the _game

- the `gameofthrones` entry in the `package.json` file;
- the file `.gameofthronesrc` formatted as _YAML_ or _JSON_;
- a file `.gameofthronesrc` with one of the managed extension;
- a file `gameofthrones.config` with one of the managed extension;
- a file `.gameofthrones/gameofthrones.config` with one of the managed extension.
- a file `.gameofthronesrc.*` with one of the [managed extensions](../extensions.md);
- a file `gameofthrones.config.*` with one of the [managed extensions](../extensions.md);
- a file `.gameofthrones/gameofthrones.config.*` with one of the [managed extensions](../extensions.md).

Even if this is not recommended, in order not to break user experience for your application, it is possible to modify this list by giving a `files` option in two ways:
Even if this is not recommended, in order not to break user experience for your application, it is possible to modify this list with the `files` option in two ways:

- by giving an array of filter functions taking as input and returning an array of file descriptions — the pre-defined `noPackageJson` filter can be used to remove the `package.json` file from the list;
- by directly providing an array of file descriptions.
Expand All @@ -140,8 +140,6 @@ A file description is:
- either a file name without extension, but with a sub-folder if needed (e.g. `.gameofthrones/gameofthrones.config`), for which all managed extensions will be tested;
- either an object literal with the `name` property containing the exact name of the file (including extension) and a `loader` property containing an instance of the loader to use.

For a list of managed extensions, see [this file](../extensions.md)

## “customLoaders” option

The default loaders list included in _confinode_ wants to be somehow exhaustive. There may anyway be cases where you want to use (very specific) file types which are not (yet) included in _confinode_. In this case, you can [create appropriate loaders](#loader) and specify them in the `customLoaders` options.
Expand Down
15 changes: 9 additions & 6 deletions doc/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This file is automatically generated. Do not edit.
</thead>
<tbody>
<tr>
<td rowspan=3>.babel.js</td><td>@babel/register-js</td><td>@babel/register</td>
<td rowspan=3>.babel.js</td><td>@babel-register-js</td><td>@babel/register</td>
</tr>
<tr>
<td>babel-core</td><td>babel-core</td>
Expand All @@ -21,14 +21,17 @@ This file is automatically generated. Do not edit.
<td>babel-register</td><td>babel-register</td>
</tr>
<tr>
<td rowspan=1>.babel.ts</td><td>@babel/register-ts</td><td>@babel/register</td>
<td rowspan=1>.babel.ts</td><td>@babel-register-ts</td><td>@babel/register</td>
</tr>
<tr>
<td rowspan=1>.buble.js</td><td>buble</td><td>buble</td>
</tr>
<tr>
<td rowspan=1>.cirru</td><td>cirru-script</td><td>cirru-script</td>
</tr>
<tr>
<td rowspan=1>.cjs</td><td>native</td><td></td>
</tr>
<tr>
<td rowspan=1>.cjsx</td><td>node-cjsx</td><td>node-cjsx</td>
</tr>
Expand Down Expand Up @@ -69,7 +72,7 @@ This file is automatically generated. Do not edit.
<td rowspan=1>.json5</td><td>json5</td><td>json5</td>
</tr>
<tr>
<td rowspan=3>.jsx</td><td>@babel/register-js</td><td>@babel/register</td>
<td rowspan=3>.jsx</td><td>@babel-register-js</td><td>@babel/register</td>
</tr>
<tr>
<td>babel-core</td><td>babel-core</td>
Expand All @@ -90,13 +93,13 @@ This file is automatically generated. Do not edit.
<td rowspan=1>.node</td><td>native</td><td></td>
</tr>
<tr>
<td rowspan=2>.toml</td><td>@iarna/toml</td><td>@iarna/toml</td>
<td rowspan=2>.toml</td><td>@iarna-toml</td><td>@iarna/toml</td>
</tr>
<tr>
<td>toml</td><td>toml</td>
</tr>
<tr>
<td rowspan=3>.ts</td><td>@babel/register-ts</td><td>@babel/register</td>
<td rowspan=3>.ts</td><td>@babel-register-ts</td><td>@babel/register</td>
</tr>
<tr>
<td>ts-node</td><td>ts-node</td>
Expand All @@ -105,7 +108,7 @@ This file is automatically generated. Do not edit.
<td>typescript-require</td><td>typescript-require</td>
</tr>
<tr>
<td rowspan=2>.tsx</td><td>@babel/register-ts</td><td>@babel/register</td>
<td rowspan=2>.tsx</td><td>@babel-register-ts</td><td>@babel/register</td>
</tr>
<tr>
<td>ts-node</td><td>ts-node</td>
Expand Down
10 changes: 4 additions & 6 deletions doc/fr/devmanual.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ Par défaut, lorsque _confinode_ recherche un fichier de configuration pour l'ap

- l'entrée `gameofthrones` du fichier `package.json` ;
- le fichier `.gameofthronesrc` au format _YAML_ ou *JSON* ;
- un fichier `.gameofthronesrc` avec l'une des extensions gérées ;
- un fichier `gameofthrones.config` avec l'une des extensions gérées ;
- un fichier `.gameofthrones/gameofthrones.config` avec l'une des extensions gérées.
- un fichier `.gameofthronesrc.*` avec l'une des [extensions gérées](../extensions.md) ;
- un fichier `gameofthrones.config.*` avec l'une des [extensions gérées](../extensions.md) ;
- un fichier `.gameofthrones/gameofthrones.config.*` avec l'une des [extensions gérées](../extensions.md).

Même si cela est déconseillé pour ne pas perturber les utilisateurs de votre application, il est possible de modifier cette liste en définissant l'option `files` de deux façons :
Même si cela est déconseillé pour ne pas perturber les utilisateurs de votre application, il est possible de modifier cette liste avec l'option `files` de deux façons :

- en donnant un tableau de fonctions de filtrage qui prennent en entrée et renvoie un tableau de descriptions de fichiers — le filtre pré-défini `noPackageJson` permet de retirer le fichier `package.json` de la liste ;
- en donnant directement un tableau de descriptions de fichiers.
Expand All @@ -140,8 +140,6 @@ Une description de fichiers se présente :
- soit sous la forme d'un nom de fichier sans extension, mais avec un éventuel nom de sous-dossier (comme par exemple `.gameofthrones/gameofthrones.config`), auquel cas toutes les extensions gérées seront testées ;
- soit sous la forme d'un littéral d'objet avec la propriété `name` qui contient le nom exact du fichier (extension incluse) et la propriété `loader` qui contient une instance du chargeur à utiliser.

Pour la liste des extensions gérées, voir [ce fichier](../extensions.md)

## Option « customLoaders »

La liste de chargeurs par défaut incluse dans _confinode_ se veut relativement exhaustive. Il peut toutefois y avoir des cas où vous souhaitez utiliser des types de fichiers (très spécifiques) qui ne sont pas (encore) inclus dans _confinode_. Dans ce cas, vous pouvez [créer les chargeurs appropriés](#chargeur) et les spécifier dans l'option `customLoaders`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LoaderDescription, RequiringLoader } from '../../Loader'
import { ignoreNonBabelAndNodeModules } from '../helpers'
import { LoaderDescription, RequiringLoader } from '../Loader'
import { ignoreNonBabelAndNodeModules } from './helpers'

/**
* Loader implementation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LoaderDescription, RequiringLoader } from '../../Loader'
import { ignoreNonBabelAndNodeModules } from '../helpers'
import { LoaderDescription, RequiringLoader } from '../Loader'
import { ignoreNonBabelAndNodeModules } from './helpers'

/**
* Loader implementation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile, readFileSync } from 'fs'
import { promisify } from 'util'

import Loader, { LoaderDescription } from '../../Loader'
import Loader, { LoaderDescription } from '../Loader'

interface Toml {
parse: { (input: string): unknown; async: (input: string) => Promise<unknown> }
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/loaders/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LoaderDescription, RequiringLoader } from '../Loader'
* Loader description.
*/
const description: LoaderDescription = {
filetypes: ['js', 'json', 'node'],
filetypes: ['js', 'cjs', 'json', 'node'],
Loader: RequiringLoader,
}
export default description

0 comments on commit 7ffc5b1

Please sign in to comment.