Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rechoir

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rechoir - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

53

index.js

@@ -5,25 +5,52 @@ const path = require('path');

const EXTRE = /^[.]?[^.]+([.].*)$/;
function req (moduleName, cwd) {
return require(resolve.sync(moduleName, {basedir: cwd}));
}
function handleLegacy (moduleName, legacyModuleName, cwd) {
try {
return req(moduleName, cwd);
} catch (err) {
try {
return req(legacyModuleName, cwd);
} catch (__) {
// nice error messages
err.message = err.message.replace(moduleName, moduleName + '\' or \'' + legacyModuleName);
throw err;
}
}
}
exports.registerFor = function (filepath, cwd) {
var ext = path.extname(filepath);
var match = EXTRE.exec(path.basename(filepath));
if (!match) {
return;
}
var ext = match[1];
if (Object.keys(require.extensions).indexOf(ext) !== -1) {
return;
}
var moduleName = interpret.extensions[ext];
if (!moduleName) {
return;
}
if (!cwd) {
cwd = path.dirname(path.resolve(filepath));
}
var moduleName = interpret.extensions[ext];
if (moduleName) {
var compiler = require(resolve.sync(moduleName, {basedir: cwd}));
var register = interpret.register[moduleName];
if (register) {
register(compiler);
}
var legacyModuleName = interpret.legacy[ext];
var config = interpret.configurations[moduleName];
var compiler;
if (legacyModuleName) {
compiler = handleLegacy(moduleName, legacyModuleName, cwd);
} else {
compiler = req(moduleName, cwd);
}
}
exports.load = function (filepath) {
exports.registerFor(filepath);
return require(filepath);
var register = interpret.register[moduleName];
if (register) {
register(compiler, config);
}
};
exports.interpret = interpret;
{
"name": "rechoir",
"description": "Require any supported file as a node module.",
"version": "0.2.2",
"version": "0.3.0",
"homepage": "https://github.com/tkellen/node-rechoir",

@@ -32,5 +32,6 @@ "author": {

"resolve": "^0.6.1",
"interpret": "^0.3.0"
"interpret": "^0.4.0"
},
"devDependencies": {
"6to5": "^2.9.4",
"LiveScript": "^1.2.0",

@@ -52,9 +53,27 @@ "chai": "^1.9.0",

"require",
"cjsx",
"co",
"coco",
"coffee-script",
"coffee",
"coffee.md",
"csv",
"es",
"es6",
"iced",
"iced.md",
"iced-coffee-script",
"ini",
"js",
"json",
"json5",
"jsx",
"react",
"litcoffee",
"liticed",
"ls",
"livescript",
"toml",
"ts",
"typescript",
"xml",

@@ -61,0 +80,0 @@ "yaml",

@@ -35,14 +35,5 @@ # rechoir [![Build Status](https://secure.travis-ci.org/tkellen/node-rechoir.png)](http://travis-ci.org/tkellen/node-rechoir)

### load (filepath)
Automatically call `requireFor`, then require the requested file and return the result.
### interpret
The underlying [interpret] module.
#### Usage
```js
var rechoir = require('rechoir');
rechoir.load('file.coffee');
```
[interpret]: https://github.com/tkellen/node-interpret

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc