Skip to content
This repository has been archived by the owner on Jan 6, 2018. It is now read-only.

Commit

Permalink
corrected code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Abadie committed Jan 29, 2016
1 parent 75978d8 commit e4b2308
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions lib/index.js
Expand Up @@ -5,25 +5,25 @@

"use strict";

var loaderUtils = require( 'loader-utils' );
var loaderUtils = require('loader-utils');

function StripFnLoader( source ) {
var query = loaderUtils.parseQuery( this.query );
function StripFnLoader(source) {
var query = loaderUtils.parseQuery(this.query);

if ( !query || !query.strip ) return;
if (!query || !query.strip) return;

var toStrip = query.strip.join( '|' );
var toStrip = query.strip.join('|');

var regexPattern = new RegExp( '(?:^|\\n)[ \\t]*(' + toStrip + ')\\(((\\"[^\\"]*\\")|(\\\'[^\\\']*\\\')|[^\\);]|\\([^\\);]*\\))*\\)[ \\t]*(?:$|[;\\n])', 'g' );
var regexPattern = new RegExp('(?:^|\\n)[ \\t]*(' + toStrip + ')\\(((\\"[^\\"]*\\")|(\\\'[^\\\']*\\\')|[^\\);]|\\([^\\);]*\\))*\\)[ \\t]*(?:$|[;\\n])', 'g');

var transformed = source.replace( regexPattern, '\n' );
var transformed = source.replace(regexPattern, '\n');

this.callback( null, transformed );
this.callback(null, transformed);
}
module.exports = StripFnLoader;

module.exports.loader = function () {
return __filename + '?' + [].slice.call( arguments, 0 ).map( function ( fn ) {
return __filename + '?' + [].slice.call(arguments, 0).map(function (fn) {
return 'strip[]=' + fn;
} ).join( ',' );
}).join(',');
};
18 changes: 9 additions & 9 deletions tests/fixtures/app/index.js
@@ -1,19 +1,19 @@
console.log( 'a console.log on the first line should get stripped' );
console.log('a console.log on the first line should get stripped');
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/

var makeFoo = function ( bar, baz ) {
var makeFoo = function (bar, baz) {
// The following 2 lines of code will be stripped with our webpack loader
var foo = function ( something ) {
var foo = function (something) {
return "foo";
};
console.log( 'some debug info' );
debug( 'better debug info' );
console.log( 'some' + "debug " + info + '(even closing parenthesis);' );
console.log( 'some' + "debug" + foo( info ) + '(even closing parenthesis)' );
console.log('some debug info');
debug('better debug info');
console.log('some' + "debug " + info + '(even closing parenthesis);');
console.log('some' + "debug" + foo(info) + '(even closing parenthesis)');
// This code would remain
return new Foo( bar, baz );
return new Foo(bar, baz);
};
console.log( 'a console.log on the last line without a semicolon should get stripped' )
console.log('a console.log on the last line without a semicolon should get stripped')

0 comments on commit e4b2308

Please sign in to comment.