strip-comments
Advanced tools
Comparing version 0.1.4 to 0.1.6
{ | ||
"name": "strip-comments", | ||
"version": "0.1.4", | ||
"version": "0.1.6", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "index.js" |
@@ -29,4 +29,8 @@ /** | ||
strip.banner = function(str) { | ||
strip.banner = function(str, opts) { | ||
opts = opts || {}; | ||
var re = new RegExp('^' + reBlock + '\\s+', 'g'); | ||
if(opts.safe) { | ||
re = new RegExp('^[^\\/\*\*?\!]' + reBlock + '\\s+', 'g'); | ||
} | ||
return str ? str.replace(re, '') : ''; | ||
@@ -33,0 +37,0 @@ }; |
{ | ||
"name": "strip-comments", | ||
"description": "Strip comments from code. Remove both line comments and block comments.", | ||
"version": "0.1.4", | ||
"version": "0.1.6", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/jonschlinkert/strip-comments", |
@@ -81,3 +81,3 @@ # strip-comments [![NPM version](https://badge.fury.io/js/strip-comments.png)](http://badge.fury.io/js/strip-comments) | ||
``` | ||
Not | ||
Not line comments | ||
@@ -88,2 +88,59 @@ ```js | ||
### block (safe) | ||
```js | ||
strip.safeBlock( str ); | ||
``` | ||
Removes | ||
```js | ||
/** | ||
* this | ||
* comment | ||
*/ | ||
``` | ||
but not comments with `/*!` or `/**!` | ||
```js | ||
/*! | ||
* this | ||
* comment | ||
*/ | ||
``` | ||
or line comments | ||
```js | ||
// This comment | ||
``` | ||
### banners | ||
```js | ||
strip.banner( str ); | ||
``` | ||
Removes the top comment in files | ||
```js | ||
/** | ||
* this | ||
* comment | ||
*/ | ||
var foo = function(/* and these */) {} | ||
``` | ||
### banners (safe) | ||
```js | ||
strip.banner( str, {safe: true} ); | ||
``` | ||
Removes the top comment in files, except for those with `/*!` or `/**!`: | ||
```js | ||
/**! | ||
* this comment won't | ||
* be removed | ||
*/ | ||
``` | ||
## Tests | ||
@@ -90,0 +147,0 @@ |
@@ -14,3 +14,3 @@ const expect = require('chai').expect; | ||
describe('banners only:', function () { | ||
describe('when `strip.banner` is used:', function () { | ||
it('should strip banners only.', function () { | ||
@@ -24,2 +24,12 @@ var fixture = file.readFileSync('test/fixtures/banner-strip.js'); | ||
describe('when `strip.banner` is used, and options.safe is specified:', function () { | ||
it('should strip banners, except for protected banners.', function () { | ||
var fixture = file.readFileSync('test/fixtures/banner-keep.js'); | ||
var actual = strip.banner(fixture, {safe: true}); | ||
var expected = file.readFileSync('test/expected/banner-protected.js'); | ||
expect(actual).to.eql(expected); | ||
}); | ||
}); | ||
describe('all except banners:', function () { | ||
@@ -26,0 +36,0 @@ it('should strip all block comments except banner.', function () { |
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
13935
13
348
160
0