Require any file extension of interpret dictionary.
Require using the dictionary of file extensions and associated module loaders from interpret dictionary. Useful, for example, to allow config files in any supported file extension, like requiring webpack config file just doing interpreting('./webpack.config')
.
Available file extensions and the associated module loader:
.js
: none.babel.js
:babel-register
.buble.js
:buble
.cirru
:cirru-script
.cjsx
:node-cjsx
.co
:coco
.coffee
:coffee-script
.coffee.md
:coffee-script
.csv
:require-csv
.eg
:earlgrey
.iced
:iced-coffee-script
.iced.md
:iced-coffee-script
.ini
:require-ini
.json
: none.json5
:json5
.jsx
:babel-register
.litcoffee
:coffee-script
.liticed
:iced-coffee-script
.ls
:livescript
.node
: none.toml
:toml-require
.ts
:ts-node
.tsx
:ts-node
.wisp
:wisp
.xml
:require-xml
.yaml
:require-yaml
.yml
:require-yaml
npm install --save interpreting
yarn add interpreting
const interpreting = require('interpreting')
// or
import interpreting from 'interpreting'
// config.babel.js
export const value = 1
interpreting('./config')
// { value: 1 }
If path
or path.*
not exists, returns null
or throws a error if options.required
is true
.
- Type:
string
string[]
File or list of files to require.
- Type:
boolean
- Default:
false
If true, at least one file must be found.
- Type:
boolean
- Default:
false
If false
returns the first found file. Otherwise, returns an array with all files founded.
- Type:
boolean
- Default:
false
If true
and multiple
is true, returns the Object.assign()
result for all files.
- interpret - A dictionary of file extensions and associated module loaders.
- Ricardo Ferro [email protected]
MIT