+4
-0
@@ -5,2 +5,5 @@ language: node_js | ||
| - "0.11" | ||
| env: | ||
| - COFFEE=coffee-script@~1.3 | ||
| - COFFEE=coffee-script@^1.7 | ||
| matrix: | ||
@@ -10,1 +13,2 @@ fast_finish: true | ||
| - node_js: 0.11 | ||
| before_script: npm install $COFFEE # install a specific version of coffee-script |
+9
-0
@@ -0,1 +1,10 @@ | ||
| v0.3.0: | ||
| date: 2015-01-10 | ||
| changes: | ||
| - Breaking: `load` method removed. | ||
| - Improved extension recognition. | ||
| - No longer fails upon dots in filenames. | ||
| - Support confuration objects. | ||
| - Support and test ES6. | ||
| - Support legacy module loading. | ||
| v0.2.2: | ||
@@ -2,0 +11,0 @@ date: 2014-12-17 |
+40
-13
@@ -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; |
+21
-2
| { | ||
| "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", |
+0
-9
@@ -35,14 +35,5 @@ # rechoir [](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 |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
6423
20.94%50
100%1
-50%14
7.69%39
-18.75%1
Infinity%+ Added
- Removed
Updated