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

ignore-styles

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ignore-styles - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

4

ignore-styles.js

@@ -26,3 +26,3 @@ export const DEFAULT_EXTENSIONS = [

export default function register(extensions = DEFAULT_EXTENSIONS) {
export default function register(extensions = DEFAULT_EXTENSIONS, handler = noOp) {
restore()

@@ -32,3 +32,3 @@

oldHandlers[ext] = require.extensions[ext]
require.extensions[ext] = noOp
require.extensions[ext] = handler
}

@@ -35,0 +35,0 @@ }

@@ -27,2 +27,3 @@ 'use strict';

var extensions = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_EXTENSIONS : arguments[0];
var handler = arguments.length <= 1 || arguments[1] === undefined ? noOp : arguments[1];

@@ -46,3 +47,3 @@ restore();

oldHandlers[ext] = require.extensions[ext];
require.extensions[ext] = noOp;
require.extensions[ext] = handler;
}

@@ -49,0 +50,0 @@ }

{
"name": "ignore-styles",
"version": "1.1.0",
"version": "1.2.0",
"description": "Ignore imported style files when running in Node",

@@ -5,0 +5,0 @@ "main": "lib/ignore-styles.js",

@@ -32,4 +32,4 @@ # ignore-styles

```javascript
import 'ignore-styles'
```js
import 'ignore-styles'
```

@@ -39,4 +39,4 @@

```javascript
require('ignore-styles')
```js
require('ignore-styles')
```

@@ -46,5 +46,5 @@

```javascript
import register from 'ignore-styles'
register(['.sass', '.scss'])
```js
import register from 'ignore-styles'
register(['.sass', '.scss'])
```

@@ -54,8 +54,28 @@

```javascript
require('ignore-styles')(['.sass', '.scss'])
```js
require('ignore-styles')(['.sass', '.scss'])
```
Enjoy!
## Custom handler
By default, a no-op handler is used that doesn't actually do anything. If you'd
like to substitute your own custom handler to do fancy things, pass it as a
second argument:
```js
import register from 'ignore-styles'
register(undefined, () => {styleName: 'fake_class_name'})
```
Why is this useful? One example is when using something like
[react-css-modules][react-css-modules]. You need the style imports to actually
return something so that you can test the components, or the wrapper component
will throw an error. Use this to provide test class names.
## License
The MIT License (MIT)
Copyright (c) 2015 Brainspace Corporation
[travis-svg]: https://img.shields.io/travis/bkonkle/ignore-styles/master.svg?style=flat-square

@@ -70,1 +90,2 @@ [travis-url]: https://travis-ci.org/bkonkle/ignore-styles

[default-extensions]: https://github.com/bkonkle/ignore-styles/blob/master/ignore-styles.js#L1
[react-css-modules]: https://github.com/gajus/react-css-modules

@@ -26,2 +26,8 @@ import {expect} from 'chai'

it('allows for a custom function to be provided instead of the no-op', () => {
const customHandler = () => ({'soup': 'No soup for you!'})
register(['.blargh'], customHandler)
expect(require.extensions['.blargh']).to.equal(customHandler)
})
})

@@ -28,0 +34,0 @@

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