Skip to content

Commit

Permalink
Build: Use prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sttk committed Apr 3, 2021
1 parent 6d28767 commit a8c7dfb
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 104 deletions.
1 change: 0 additions & 1 deletion .github/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.

15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ This module, in conjunction with [interpret]-like objects, can register any file

**Note:** While `rechoir` will automatically load and register transpilers like `coffee-script`, you must provide a local installation. The transpilers are **not** bundled with this module.


## rechoir for enterprise

Available as part of the Tidelift Subscription.

The maintainers of `rechoir` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.][tidelift-url]


## Usage

Expand All @@ -42,13 +40,13 @@ console.log(require('./test/fixtures/test.toml'));

### `prepare(config, filepath, [cwd], [noThrow])`

Look for a module loader associated with the provided file and attempt require it. If necessary, run any setup required to inject it into [require.extensions].
Look for a module loader associated with the provided file and attempt require it. If necessary, run any setup required to inject it into [require.extensions].

`config` An [interpret]-like configuration object.

`filepath` A file whose type you'd like to register a module loader for.

`cwd` An optional path to start searching for the module required to load the requested file. Defaults to the directory of `filepath`.
`cwd` An optional path to start searching for the module required to load the requested file. Defaults to the directory of `filepath`.

`noThrow` An optional boolean indicating if the method should avoid throwing.

Expand All @@ -62,21 +60,18 @@ If a loader is already registered, this will simply return `true`.

MIT

<!-- prettier-ignore-start -->
[interpret]: https://github.com/gulpjs/interpret
[require.extensions]: https://nodejs.org/api/modules.html#modules_require_extensions
[Liftoff]: https://github.com/js-cli/js-liftoff

[liftoff]: https://github.com/js-cli/js-liftoff
[downloads-image]: https://img.shields.io/npm/dm/rechoir.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/rechoir
[npm-image]: https://img.shields.io/npm/v/rechoir.svg?style=flat-square

[travis-url]: https://travis-ci.org/gulpjs/rechoir
[travis-image]: https://img.shields.io/travis/gulpjs/rechoir.svg?label=travis-ci

[appveyor-url]: https://ci.appveyor.com/project/gulpjs/rechoir
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/rechoir.svg?label=appveyor

[coveralls-url]: https://coveralls.io/r/gulpjs/rechoir
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/rechoir/master.svg

[tidelift-url]: https://tidelift.com/subscription/pkg/npm-rechoir?utm_source=npm-rechoir&utm_medium=referral&utm_campaign=enterprise&utm_term=repo
<!-- prettier-ignore-end -->
14 changes: 7 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
environment:
matrix:
# node.js
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"
- nodejs_version: '0.10'
- nodejs_version: '0.12'
- nodejs_version: '4'
- nodejs_version: '6'
- nodejs_version: '8'
- nodejs_version: '10'

install:
- ps: Install-Product node $env:nodejs_version
Expand All @@ -23,4 +23,4 @@ test_script:
build: off

# build version format
version: "{build}"
version: '{build}'
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var extension = require('./lib/extension');
var normalize = require('./lib/normalize');
var register = require('./lib/register');

exports.prepare = function(extensions, filepath, cwd, nothrow) {
exports.prepare = function (extensions, filepath, cwd, nothrow) {
var config, usedExtension, err, option, attempt, error;
var attempts = [];
var onlyErrors = true;
var exts = extension(filepath);

if (exts) {
exts.some(function(ext) {
exts.some(function (ext) {
usedExtension = ext;
config = normalize(extensions[ext]);
return !!config;
Expand Down Expand Up @@ -40,7 +40,7 @@ exports.prepare = function(extensions, filepath, cwd, nothrow) {
for (var i in config) {
option = config[i];
attempt = register(cwd, option.module, option.register);
error = (attempt instanceof Error) ? attempt : null;
error = attempt instanceof Error ? attempt : null;
if (error) {
attempt = null;
}
Expand All @@ -55,7 +55,9 @@ exports.prepare = function(extensions, filepath, cwd, nothrow) {
}
}
if (onlyErrors) {
err = new Error('Unable to use specified module loaders for "' + usedExtension + '".');
err = new Error(
'Unable to use specified module loaders for "' + usedExtension + '".'
);
err.failures = attempts;
if (nothrow) {
return err;
Expand Down
4 changes: 2 additions & 2 deletions lib/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var path = require('path');
var EXTRE = /\.[^.]*/g;
var LONGEXTRE = /^[.]?[^.]+([.].+[^.])$/;

module.exports = function(input) {
module.exports = function (input) {
var basename = path.basename(input);
var longExtension = LONGEXTRE.exec(basename);
if (!longExtension) {
Expand All @@ -13,7 +13,7 @@ module.exports = function(input) {
if (!possibleExtensions) {
return;
}
return possibleExtensions.map(function(_, idx, exts) {
return possibleExtensions.map(function (_, idx, exts) {
return exts.slice(idx).join('');
});
};
2 changes: 1 addition & 1 deletion lib/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function normalizer(config) {
return config;
}

module.exports = function(config) {
module.exports = function (config) {
if (Array.isArray(config)) {
return config.map(normalizer);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/register.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var resolve = require('resolve');

module.exports = function(cwd, moduleName, register) {
module.exports = function (cwd, moduleName, register) {
var result;
try {
var modulePath = resolve.sync(moduleName, { basedir: cwd });
Expand Down

0 comments on commit a8c7dfb

Please sign in to comment.