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

vigour-util

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vigour-util - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

8

package.json
{
"name": "vigour-util",
"version": "2.0.1",
"version": "2.0.2",
"author": "Vigour.io <dev@vigour.io>",

@@ -43,6 +43,12 @@ "scripts": {

"nightmare": "^2.2.0",
"node-lessify": "^0.1.1",
"tap-difflet": "^0.4.0",
"tape": "^4.5.1",
"vigour-base": "^2.0.0"
},
"browserify": {
"transform": [
"node-lessify"
]
}
}

4

README.md

@@ -408,5 +408,7 @@ <!-- VDOC.badges travis; standard; npm -->

```javascript
require('vigour-util/require')
var enhanceRequire = require('vigour-util/require')
enhanceRequire()
require('styles.less') // ignored in node, processed elsewhere
// Don't forget to add a browserify transform or similar for non-node
enhanceRequire.restore()
```

@@ -9,2 +9,4 @@ 'use strict'

var originalRequire = require
if (isNode) { // else let browserify (or similar) do it

@@ -34,5 +36,19 @@ var require = function require (path) {

require.next = Module.prototype.require
module.exports = enhanceRequire
} else {
module.exports = enhanceRequireMock
}
function enhanceRequire (options) {
Module.prototype.require = require
}
enhanceRequire.restore = function restoreRequire () {
Module.prototype.require = originalRequire
}
module.exports = {}
function enhanceRequireMock (options) {
// Do nothing
}
enhanceRequireMock.restore = function restoreRequireMock () {
// Do nothing
}
'use strict'
var test = require('tape')
var isNode = require('../is/node')
test('require', function (t) {
t.plan(1)
require('../require')
// require('./_files/styles.less')
// require('./_files/styles.css')
// require('./_files/scratch/this-should-be-ignored')
t.equals(1, 1, 'required styles should be ignored in node')
t.plan(3)
var enhanceRequire = require('../require')
var count = 0
try {
require('./_files/styles.less')
} catch (e) {
count += 1
}
t.equals(count, isNode ? 1 : 0, "`require('vigour-util/require')` shouldn't have any effect")
enhanceRequire()
count = 0
try {
require('./_files/styles.less')
require('./_files/styles.css')
require('./_files/scratch/this-should-be-ignored')
} catch (e) {
count += 1
}
t.equals(count, 0, "`require('vigour-util/require')()` makes `require` ignore styles and scratch")
enhanceRequire.restore()
count = 0
try {
require('./_files/styles.less')
} catch (e) {
count += 1
}
t.equals(count, isNode ? 1 : 0, "`require('vigour-util/require').restore()` should restore the original `require`")
})

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