@regru/bem-loader
Advanced tools
Comparing version 1.0.1 to 1.1.1
@@ -41,4 +41,6 @@ const loaderUtils = require('loader-utils'); | ||
if ( typeof err === 'string' ) { | ||
this.emitWarning( err ); | ||
const emitMethod = options.strict ? 'emitError' : 'emitWarning'; | ||
this[emitMethod]( err ); | ||
return void next( null ); | ||
@@ -45,0 +47,0 @@ } |
@@ -34,6 +34,8 @@ const { promisify } = require('util'); | ||
const emitMethod = options.strict ? 'emitError' : 'emitWarning'; | ||
return Bluebird.filter( promises, res => res ) | ||
.spread( function( directory ) { | ||
if ( !directory ) { | ||
context.emitWarning( `Entity ${block.toString()} not found` ); | ||
context[emitMethod]( `Entity ${block.toString()} not found` ); | ||
@@ -47,3 +49,3 @@ return []; | ||
if ( !matches.length ) { | ||
context.emitWarning( `No files found for ${block.toString()}` ); | ||
context[emitMethod]( `No files found for ${block.toString()}` ); | ||
@@ -50,0 +52,0 @@ return []; |
{ | ||
"name": "@regru/bem-loader", | ||
"version": "1.0.1", | ||
"version": "1.1.1", | ||
"description": "Webpack loader for BEM projects", | ||
@@ -15,4 +15,5 @@ "homepage": "https://github.com/shifteee/bem-loader.git", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "7.1.1", | ||
"eslint": "^4.19.1", | ||
"mocha": "^3.2.0", | ||
"mocha": "6.2.2", | ||
"sinon": "^1.17.6" | ||
@@ -19,0 +20,0 @@ }, |
@@ -28,3 +28,4 @@ Bem-loader | ||
elemDelim: '__' // optional, default '__' | ||
modDelim: '_' //optional, default '_' | ||
modDelim: '_' //optional, default '_', | ||
strict: false //optional, default false. throws if no files is found | ||
}, | ||
@@ -31,0 +32,0 @@ ``` |
const path = require('path'); | ||
const search = require('../libs/search'); | ||
const expect = require('chai').expect; | ||
const chai = require('chai'); | ||
const chaiAsPromised = require('chai-as-promised'); | ||
const sinon = require('sinon'); | ||
const expect = chai.expect; | ||
chai.use( chaiAsPromised ); | ||
const block = { | ||
@@ -23,10 +27,12 @@ block : 'b-block-two', | ||
emitWarning() {}, | ||
emitError() {}, | ||
}; | ||
describe( 'search', function() { | ||
let spy; | ||
let warningSpy; | ||
let errorSpy; | ||
beforeEach( function() { | ||
spy = sinon.spy( context , 'emitWarning' ); | ||
warningSpy = sinon.spy( context , 'emitWarning' ); | ||
errorSpy = sinon.spy( context , 'emitError' ); | ||
} ); | ||
@@ -36,2 +42,3 @@ | ||
context.emitWarning.restore(); | ||
context.emitError.restore(); | ||
} ); | ||
@@ -42,6 +49,15 @@ | ||
.then( function() { | ||
expect( spy.called ).to.be.true; | ||
expect( warningSpy.called ).to.be.true; | ||
} ); | ||
} ); | ||
it( 'should emit error if found nothing and options.strict == true', function() { | ||
return search( context, { block: 'nonexistent' }, { | ||
levels, | ||
strict : true, | ||
} ).then( function() { | ||
expect( errorSpy.called ).to.be.true; | ||
} ); | ||
} ); | ||
it( 'should throw exception if levels not set', function() { | ||
@@ -48,0 +64,0 @@ expect( () => search( context, block ) ).to.throw(); |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
15063
388
37
0
6