diff options
Diffstat (limited to 'node_modules/istanbul-lib-hook')
-rw-r--r-- | node_modules/istanbul-lib-hook/CHANGELOG.md | 72 | ||||
-rw-r--r-- | node_modules/istanbul-lib-hook/LICENSE | 24 | ||||
-rw-r--r-- | node_modules/istanbul-lib-hook/README.md | 7 | ||||
-rw-r--r-- | node_modules/istanbul-lib-hook/index.js | 5 | ||||
-rw-r--r-- | node_modules/istanbul-lib-hook/lib/hook.js | 223 | ||||
-rw-r--r-- | node_modules/istanbul-lib-hook/package.json | 36 |
6 files changed, 0 insertions, 367 deletions
diff --git a/node_modules/istanbul-lib-hook/CHANGELOG.md b/node_modules/istanbul-lib-hook/CHANGELOG.md deleted file mode 100644 index 817b6a345..000000000 --- a/node_modules/istanbul-lib-hook/CHANGELOG.md +++ /dev/null @@ -1,72 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -<a name="1.2.2"></a> -## [1.2.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-hook@1.1.0...istanbul-lib-hook@1.2.2) (2018-09-05) - - -### Bug Fixes - -* Tweak package.json files for republish as latest 1.x. ([#217](https://github.com/istanbuljs/istanbuljs/issues/217)) ([420481d](https://github.com/istanbuljs/istanbuljs/commit/420481d)), closes [#216](https://github.com/istanbuljs/istanbuljs/issues/216) - - -### BREAKING CHANGES - -* leaked into 1.x modules but it was thought they were -never released to latest. Apparently releasing 2.x to latest makes -those unwanted versions of 1.x available. - -This patch sets all modules to the latest 1.x version (4.x for -test-exclude). This will allow a new release to be made to revert -release of the breaking changes. - -Stop upgrading npm to latest for testing as it's not compatible with -node 4.x. - - - - -<a name="1.1.0"></a> -# [1.1.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-hook@1.0.7...istanbul-lib-hook@1.1.0) (2017-10-21) - - -### Features - -* hook vm.runInContext ([#90](https://github.com/istanbuljs/istanbuljs/issues/90)) ([9659936](https://github.com/istanbuljs/istanbuljs/commit/9659936)) - - - - -<a name="1.0.7"></a> -## [1.0.7](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-hook@1.0.6...istanbul-lib-hook@1.0.7) (2017-05-27) - - - - -<a name="1.0.6"></a> -## [1.0.6](https://github.com/istanbuljs/istanbul-lib-hook/compare/istanbul-lib-hook@1.0.5...istanbul-lib-hook@1.0.6) (2017-04-29) - - - - -<a name="1.0.5"></a> -## [1.0.5](https://github.com/istanbuljs/istanbul-lib-hook/compare/istanbul-lib-hook@1.0.4...istanbul-lib-hook@1.0.5) (2017-03-27) - -<a name="1.0.4"></a> -## [1.0.4](https://github.com/istanbuljs/istanbul-lib-hook/compare/istanbul-lib-hook@1.0.3...istanbul-lib-hook@1.0.4) (2017-03-21) - -<a name="1.0.3"></a> -## [1.0.3](https://github.com/istanbuljs/istanbul-lib-hook/compare/istanbul-lib-hook@1.0.2...istanbul-lib-hook@1.0.3) (2017-03-21) - -<a name="1.0.2"></a> -## [1.0.2](https://github.com/istanbuljs/istanbul-lib-hook/compare/istanbul-lib-hook@1.0.0...istanbul-lib-hook@1.0.2) (2017-03-21) - -<a name="1.0.0"></a> -# [1.0.0](https://github.com/istanbuljs/istanbul-lib-hook/compare/v1.0.0-alpha.3...v1.0.0) (2017-01-17) - - -### Bug Fixes - -* update append-transform to version that fixes issues run into by ts-node ([f4aaf79](https://github.com/istanbuljs/istanbul-lib-hook/commit/f4aaf79)) diff --git a/node_modules/istanbul-lib-hook/LICENSE b/node_modules/istanbul-lib-hook/LICENSE deleted file mode 100644 index d55d2916e..000000000 --- a/node_modules/istanbul-lib-hook/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright 2012-2015 Yahoo! Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Yahoo! Inc. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/istanbul-lib-hook/README.md b/node_modules/istanbul-lib-hook/README.md deleted file mode 100644 index 0f3ec181d..000000000 --- a/node_modules/istanbul-lib-hook/README.md +++ /dev/null @@ -1,7 +0,0 @@ -istanbul-lib-hook -================= - -[![Greenkeeper badge](https://badges.greenkeeper.io/istanbuljs/istanbul-lib-hook.svg)](https://greenkeeper.io/) -[![Build Status](https://travis-ci.org/istanbuljs/istanbul-lib-hook.svg?branch=master)](https://travis-ci.org/istanbuljs/istanbul-lib-hook) - -Hooks for require, vm and script used in istanbul diff --git a/node_modules/istanbul-lib-hook/index.js b/node_modules/istanbul-lib-hook/index.js deleted file mode 100644 index c59df033b..000000000 --- a/node_modules/istanbul-lib-hook/index.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -module.exports = require('./lib/hook'); diff --git a/node_modules/istanbul-lib-hook/lib/hook.js b/node_modules/istanbul-lib-hook/lib/hook.js deleted file mode 100644 index df3162fa2..000000000 --- a/node_modules/istanbul-lib-hook/lib/hook.js +++ /dev/null @@ -1,223 +0,0 @@ -/* - Copyright 2012-2015, Yahoo Inc. - Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. - */ -var path = require('path'), - vm = require('vm'), - appendTransform = require('append-transform'), - originalCreateScript = vm.createScript, - originalRunInThisContext = vm.runInThisContext, - originalRunInContext = vm.runInContext; - -function transformFn(matcher, transformer, verbose) { - - return function (code, filename) { - var shouldHook = typeof filename === 'string' && matcher(path.resolve(filename)), - transformed, - changed = false; - - if (shouldHook) { - if (verbose) { - console.error('Module load hook: transform [' + filename + ']'); - } - try { - transformed = transformer(code, filename); - changed = true; - } catch (ex) { - console.error('Transformation error for', filename, '; return original code'); - console.error(ex.message || String(ex)); - if (verbose) { - console.error(ex.stack); - } - transformed = code; - } - } else { - transformed = code; - } - return { code: transformed, changed: changed }; - }; -} -/** - * unloads the required caches, removing all files that would have matched - * the supplied matcher. - * @param {Function} matcher - the match function that accepts a file name and - * returns if that file should be unloaded from the cache. - */ -function unloadRequireCache(matcher) { - /* istanbul ignore else: impossible to test */ - if (matcher && typeof require !== 'undefined' && require && require.cache) { - Object.keys(require.cache).forEach(function (filename) { - if (matcher(filename)) { - delete require.cache[filename]; - } - }); - } -} -/** - * hooks `require` to return transformed code to the node module loader. - * Exceptions in the transform result in the original code being used instead. - * @method hookRequire - * @static - * @param matcher {Function(filePath)} a function that is called with the absolute path to the file being - * `require`-d. Should return a truthy value when transformations need to be applied to the code, a falsy value otherwise - * @param transformer {Function(code, filePath)} a function called with the original code and the associated path of the file - * from where the code was loaded. Should return the transformed code. - * @param options {Object} options Optional. - * @param {Boolean} [options.verbose] write a line to standard error every time the transformer is called - * @param {Function} [options.postLoadHook] a function that is called with the name of the file being - * required. This is called after the require is processed irrespective of whether it was transformed. - * @returns {Function} a reset function that can be called to remove the hook - */ -function hookRequire(matcher, transformer, options) { - options = options || {}; - var extensions, - disable = false, - fn = transformFn(matcher, transformer, options.verbose), - postLoadHook = options.postLoadHook && - typeof options.postLoadHook === 'function' ? options.postLoadHook : null; - - extensions = options.extensions || ['.js']; - - extensions.forEach(function(ext){ - appendTransform(function (code, filename) { - if (disable) { - return code; - } - var ret = fn(code, filename); - if (postLoadHook) { - postLoadHook(filename); - } - return ret.code; - }, ext); - }); - - return function () { - disable = true; - }; -} -/** - * hooks `vm.createScript` to return transformed code out of which a `Script` object will be created. - * Exceptions in the transform result in the original code being used instead. - * @method hookCreateScript - * @static - * @param matcher {Function(filePath)} a function that is called with the filename passed to `vm.createScript` - * Should return a truthy value when transformations need to be applied to the code, a falsy value otherwise - * @param transformer {Function(code, filePath)} a function called with the original code and the filename passed to - * `vm.createScript`. Should return the transformed code. - * @param options {Object} options Optional. - * @param {Boolean} [options.verbose] write a line to standard error every time the transformer is called - */ -function hookCreateScript(matcher, transformer, opts) { - opts = opts || {}; - var fn = transformFn(matcher, transformer, opts.verbose); - vm.createScript = function (code, file) { - var ret = fn(code, file); - return originalCreateScript(ret.code, file); - }; -} -/** - * unhooks vm.createScript, restoring it to its original state. - * @method unhookCreateScript - * @static - */ -function unhookCreateScript() { - vm.createScript = originalCreateScript; -} -/** - * hooks `vm.runInThisContext` to return transformed code. - * @method hookRunInThisContext - * @static - * @param matcher {Function(filePath)} a function that is called with the filename passed to `vm.createScript` - * Should return a truthy value when transformations need to be applied to the code, a falsy value otherwise - * @param transformer {Function(code, filePath)} a function called with the original code and the filename passed to - * `vm.createScript`. Should return the transformed code. - * @param opts {Object} [opts={}] options - * @param {Boolean} [opts.verbose] write a line to standard error every time the transformer is called - */ -function hookRunInThisContext(matcher, transformer, opts) { - opts = opts || {}; - var fn = transformFn(matcher, transformer, opts.verbose); - vm.runInThisContext = function (code, file) { - var ret = fn(code, file); - return originalRunInThisContext(ret.code, file); - }; -} -/** - * unhooks vm.runInThisContext, restoring it to its original state. - * @method unhookRunInThisContext - * @static - */ -function unhookRunInThisContext() { - vm.runInThisContext = originalRunInThisContext; -} -/** - * hooks `vm.runInContext` to return transformed code. - * @method hookRunInContext - * @static - * @param matcher {Function(filePath)} a function that is called with the filename passed to `vm.createScript` - * Should return a truthy value when transformations need to be applied to the code, a falsy value otherwise - * @param transformer {Function(code, filePath)} a function called with the original code and the filename passed to - * `vm.createScript`. Should return the transformed code. - * @param opts {Object} [opts={}] options - * @param {Boolean} [options.verbose] write a line to standard error every time the transformer is called - */ -function hookRunInContext(matcher, transformer, opts) { - opts = opts || {}; - var fn = transformFn(matcher, transformer, opts.verbose); - vm.runInContext = function (code, context, file) { - var ret = fn(code, file); - var coverageVariable = opts.coverageVariable || '__coverage__'; - // Refer coverage variable in context to global coverage variable. - // So that coverage data will be written in global coverage variable for unit tests run in vm.runInContext. - // If all unit tests are run in vm.runInContext, no global coverage variable will be generated. - // Thus initialize a global coverage variable here. - if (!global[coverageVariable]) { - global[coverageVariable] = {}; - } - context[coverageVariable] = global[coverageVariable]; - return originalRunInContext(ret.code, context, file); - }; - -} -/** - * unhooks vm.runInContext, restoring it to its original state. - * @method unhookRunInContext - * @static - */ -function unhookRunInContext() { - vm.runInContext = originalRunInContext; -} -/** - * istanbul-lib-hook provides mechanisms to transform code in the scope of `require`, - * `vm.createScript`, `vm.runInThisContext` etc. - * - * This mechanism is general and relies on a user-supplied `matcher` function that - * determines when transformations should be performed and a user-supplied `transformer` - * function that performs the actual transform. Instrumenting code for coverage is - * one specific example of useful hooking. - * - * Note that both the `matcher` and `transformer` must execute synchronously. - * - * @module Exports - * @example - * var hook = require('istanbul-lib-hook'), - * myMatcher = function (file) { return file.match(/foo/); }, - * myTransformer = function (code, file) { - * return 'console.log("' + file + '");' + code; - * }; - * - * hook.hookRequire(myMatcher, myTransformer); - * var foo = require('foo'); //will now print foo's module path to console - */ -module.exports = { - hookRequire: hookRequire, - hookCreateScript: hookCreateScript, - unhookCreateScript: unhookCreateScript, - hookRunInThisContext : hookRunInThisContext, - unhookRunInThisContext : unhookRunInThisContext, - hookRunInContext : hookRunInContext, - unhookRunInContext : unhookRunInContext, - unloadRequireCache: unloadRequireCache -}; - - diff --git a/node_modules/istanbul-lib-hook/package.json b/node_modules/istanbul-lib-hook/package.json deleted file mode 100644 index a4ff329e4..000000000 --- a/node_modules/istanbul-lib-hook/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "istanbul-lib-hook", - "version": "1.2.2", - "description": "Hooks for require, vm and script used in istanbul", - "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>", - "main": "index.js", - "files": [ - "lib", - "index.js" - ], - "scripts": { - "pretest": "jshint index.js lib/ test/", - "test": "mocha" - }, - "dependencies": { - "append-transform": "^0.4.0" - }, - "devDependencies": { - "chai": "^3.0.0", - "jshint": "^2.8.0", - "mocha": "^3.2.0" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/istanbuljs/istanbuljs.git" - }, - "keywords": [ - "istanbul", - "hook" - ], - "license": "BSD-3-Clause", - "bugs": { - "url": "https://github.com/istanbuljs/istanbuljs/issues" - }, - "homepage": "https://github.com/istanbuljs/istanbuljs#readme" -} |