rewiremock
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -22,2 +22,3 @@ 'use strict'; | ||
var FS_MODULE_NAME = 'fs'; | ||
var DEFAULT_CONFIG_NAMES = ['webpack.config.js', 'webpack.config.babel.js']; | ||
@@ -33,3 +34,3 @@ | ||
try { | ||
var fs = require('fs'); | ||
var fs = require(FS_MODULE_NAME); | ||
return !fs.accessSync(path, fs.F_OK) && path; | ||
@@ -36,0 +37,0 @@ } catch (e) { |
{ | ||
"name": "rewiremock", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Easy and es6 compatible dependency mocking tool.", | ||
@@ -11,3 +11,3 @@ "main": "lib/index.js", | ||
"test:pick": "BABEL_ENV=test mocha --compilers js:babel-core/register", | ||
"test:karma": "node ./node_modules/karma/bin/karma --single-run --browsers PhantomJS", | ||
"test:karma": "node ./node_modules/karma/bin/karma start --single-run --browsers PhantomJS", | ||
"test:browser": "node ./node_modules/karma/bin/karma start --browsers Chrome", | ||
@@ -21,3 +21,4 @@ "build": "babel src -d lib", | ||
"lib", | ||
"webpack" | ||
"webpack", | ||
"rewiremock.d.ts" | ||
], | ||
@@ -24,0 +25,0 @@ "keywords": [ |
@@ -1,9 +0,13 @@ | ||
const ConcatSource = require("webpack-sources").ConcatSource; | ||
const {relative} = require("path"); | ||
const {ConcatSource} = require("webpack-sources"); | ||
const injectString = "/***/if(typeof __webpack_require__!=='undefined'){__webpack_require__ = __webpack_require__('./webpack/interceptor.js')(__webpack_require__, module);}\n"; | ||
const file = './' + relative(process.cwd(), __dirname + '/interceptor.js'); | ||
const injectString = "/***/if(typeof __webpack_require__!=='undefined'){__webpack_require__ = __webpack_require__('" + file + "')(__webpack_require__, module);}\n"; | ||
class RewiremockPlugin { | ||
apply(compiler) { | ||
compiler.plugin('compilation', function (compilation) { | ||
compilation.moduleTemplate.plugin("render", function (moduleSource, module) { | ||
compilation.moduleTemplate.plugin("render", function (moduleSource) { | ||
const source = new ConcatSource(); | ||
@@ -10,0 +14,0 @@ source.add(injectString); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83444
39
1835