diff options
Diffstat (limited to 'tools/node_modules/eslint/node_modules/require-uncached')
4 files changed, 174 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/require-uncached/index.js b/tools/node_modules/eslint/node_modules/require-uncached/index.js new file mode 100644 index 0000000000..63dfada3ec --- /dev/null +++ b/tools/node_modules/eslint/node_modules/require-uncached/index.js @@ -0,0 +1,29 @@ +'use strict'; +var path = require('path'); +var resolveFrom = require('resolve-from'); +var callerPath = require('caller-path'); + +module.exports = function (moduleId) { + if (typeof moduleId !== 'string') { + throw new TypeError('Expected a string'); + } + + var filePath = resolveFrom(path.dirname(callerPath()), moduleId); + + // delete itself from module parent + if (require.cache[filePath] && require.cache[filePath].parent) { + var i = require.cache[filePath].parent.children.length; + + while (i--) { + if (require.cache[filePath].parent.children[i].id === filePath) { + require.cache[filePath].parent.children.splice(i, 1); + } + } + } + + // delete module from cache + delete require.cache[filePath]; + + // return fresh module + return require(filePath); +}; diff --git a/tools/node_modules/eslint/node_modules/require-uncached/license b/tools/node_modules/eslint/node_modules/require-uncached/license new file mode 100644 index 0000000000..654d0bfe94 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/require-uncached/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/eslint/node_modules/require-uncached/package.json b/tools/node_modules/eslint/node_modules/require-uncached/package.json new file mode 100644 index 0000000000..ea49c4321d --- /dev/null +++ b/tools/node_modules/eslint/node_modules/require-uncached/package.json @@ -0,0 +1,77 @@ +{ + "_from": "require-uncached@^1.0.3", + "_id": "require-uncached@1.0.3", + "_inBundle": false, + "_integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "_location": "/eslint/require-uncached", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "require-uncached@^1.0.3", + "name": "require-uncached", + "escapedName": "require-uncached", + "rawSpec": "^1.0.3", + "saveSpec": null, + "fetchSpec": "^1.0.3" + }, + "_requiredBy": [ + "/eslint" + ], + "_resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "_shasum": "4e0d56d6c9662fd31e43011c4b95aa49955421d3", + "_spec": "require-uncached@^1.0.3", + "_where": "/Users/cjihrig/iojs/node/tools/eslint-tmp/node_modules/eslint", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/require-uncached/issues" + }, + "bundleDependencies": false, + "dependencies": { + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" + }, + "deprecated": false, + "description": "Require a module bypassing the cache", + "devDependencies": { + "ava": "*", + "heapdump": "^0.3.7", + "xo": "^0.16.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/require-uncached#readme", + "keywords": [ + "require", + "cache", + "uncache", + "uncached", + "module", + "fresh", + "bypass" + ], + "license": "MIT", + "name": "require-uncached", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/require-uncached.git" + }, + "scripts": { + "heapdump": "node heapdump.js", + "test": "xo && ava" + }, + "version": "1.0.3", + "xo": { + "rules": { + "import/no-dynamic-require": "off" + } + } +} diff --git a/tools/node_modules/eslint/node_modules/require-uncached/readme.md b/tools/node_modules/eslint/node_modules/require-uncached/readme.md new file mode 100644 index 0000000000..baa6cc2b39 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/require-uncached/readme.md @@ -0,0 +1,47 @@ +# require-uncached [![Build Status](https://travis-ci.org/sindresorhus/require-uncached.svg?branch=master)](https://travis-ci.org/sindresorhus/require-uncached) + +> Require a module bypassing the [cache](https://nodejs.org/api/modules.html#modules_caching) + +Useful for testing purposes when you need to freshly require a module. + + +## Install + +``` +$ npm install --save require-uncached +``` + + +## Usage + +```js +// foo.js +let i = 0; +module.exports = () => ++i; +``` + +```js +const requireUncached = require('require-uncached'); + +require('./foo')(); +//=> 1 + +require('./foo')(); +//=> 2 + +requireUncached('./foo')(); +//=> 1 + +requireUncached('./foo')(); +//=> 1 +``` + + +## Related + +- [clear-require](https://github.com/sindresorhus/clear-require) - Clear a module from the require cache + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) |