massick / gulp-strip-code

A gulp plugin to remove parts of code based on regular expressions.
MIT License
25 stars 6 forks source link

Option to keep the comments #1

Closed samvloeberghs closed 8 years ago

samvloeberghs commented 8 years ago

Hi,

Is it possible to add an option to preserve the comments that identify the block to strip? I can provide a pull request if you like?

So by default remove the comments If setting the option keep_comments: true, it retains the comments

Kr Sam V.

massick commented 8 years ago

Sure, feel free to create a PR if you want.

samvloeberghs commented 8 years ago

Is it possible that your tests fail? I did a clean checkout:

npm install npm test

C:\Data\code\gulp-strip-code>npm test

gulp-strip-code@0.1.2 test C:\Data\code\gulp-strip-code mocha

(node) child_process: options.customFds option is deprecated. Use options.stdio

gulp-replace stripCode() 1) should remove pattern 2) should remove code from start_comment to end_comment on a buffer V should error on a stream

1 passing (27ms) 2 failing

1) gulp-replace stripCode() should remove pattern:

  AssertionError: expected 'function() {\r\n\r\n    doSomething();\r\n\r\n}'
  + expected - actual

  +"function() {\r\n    doSomething();\r\n}"
  -"function() {\r\n\r\n    doSomething();\r\n\r\n}"

  at Assertion.fail (C:\Data\code\gulp-strip-code\node_modules\should\lib\as
  at Assertion.prop.(anonymous function) (C:\Data\code\gulp-strip-code\node_
  at Stream.<anonymous> (C:\Data\code\gulp-strip-code\test\index.js:33:49)
  at emitOne (events.js:77:13)
  at Stream.emit (events.js:169:7)
  at queueData (C:\Data\code\gulp-strip-code\node_modules\map-stream\index.j
  at next (C:\Data\code\gulp-strip-code\node_modules\map-stream\index.js:71:
  at C:\Data\code\gulp-strip-code\node_modules\map-stream\index.js:85:7
  at doStrip (C:\Data\code\gulp-strip-code\index.js:18:20)
  at wrappedMapper (C:\Data\code\gulp-strip-code\node_modules\map-stream\ind
  at Stream.stream.write (C:\Data\code\gulp-strip-code\node_modules\map-stre
  at Context.<anonymous> (C:\Data\code\gulp-strip-code\test\index.js:36:20)
  at Test.Runnable.run (C:\Data\code\gulp-strip-code\node_modules\mocha\lib\
  at Runner.runTest (C:\Data\code\gulp-strip-code\node_modules\mocha\lib\run
  at C:\Data\code\gulp-strip-code\node_modules\mocha\lib\runner.js:451:12
  at next (C:\Data\code\gulp-strip-code\node_modules\mocha\lib\runner.js:298
  at C:\Data\code\gulp-strip-code\node_modules\mocha\lib\runner.js:308:7
  at next (C:\Data\code\gulp-strip-code\node_modules\mocha\lib\runner.js:246
  at Immediate._onImmediate (C:\Data\code\gulp-strip-code\node_modules\mocha
  at processImmediate [as _immediateCallback] (timers.js:368:17)

2) gulp-replace stripCode() should remove code from start_comment to end_comme

  AssertionError: expected '\r\n/*! i18n IT start */\r\n.test {\r\n    color
  + expected - actual

  +"/*! i18n IT start */\r\n.test {\r\n    color: blue;\r\n}\r\n/*! i18n IT
  -"\r\n/*! i18n IT start */\r\n.test {\r\n    color: blue;\r\n}\r\n/*! i18n

  at Assertion.fail (C:\Data\code\gulp-strip-code\node_modules\should\lib\as
  at Assertion.prop.(anonymous function) (C:\Data\code\gulp-strip-code\node_
  at Stream.<anonymous> (C:\Data\code\gulp-strip-code\test\index.js:53:49)
  at emitOne (events.js:77:13)
  at Stream.emit (events.js:169:7)
  at queueData (C:\Data\code\gulp-strip-code\node_modules\map-stream\index.j
  at next (C:\Data\code\gulp-strip-code\node_modules\map-stream\index.js:71:
  at C:\Data\code\gulp-strip-code\node_modules\map-stream\index.js:85:7
  at doStrip (C:\Data\code\gulp-strip-code\index.js:18:20)
  at wrappedMapper (C:\Data\code\gulp-strip-code\node_modules\map-stream\ind
  at Stream.stream.write (C:\Data\code\gulp-strip-code\node_modules\map-stre
  at Context.<anonymous> (C:\Data\code\gulp-strip-code\test\index.js:56:20)
  at Test.Runnable.run (C:\Data\code\gulp-strip-code\node_modules\mocha\lib\
  at Runner.runTest (C:\Data\code\gulp-strip-code\node_modules\mocha\lib\run
  at C:\Data\code\gulp-strip-code\node_modules\mocha\lib\runner.js:451:12
  at next (C:\Data\code\gulp-strip-code\node_modules\mocha\lib\runner.js:298
  at C:\Data\code\gulp-strip-code\node_modules\mocha\lib\runner.js:308:7
  at next (C:\Data\code\gulp-strip-code\node_modules\mocha\lib\runner.js:246
  at Immediate._onImmediate (C:\Data\code\gulp-strip-code\node_modules\mocha
  at processImmediate [as _immediateCallback] (timers.js:368:17)

npm ERR! Test failed. See above for more details.

massick commented 8 years ago

I will check this evening, they were working last time I tried.

samvloeberghs commented 8 years ago

They are actually failing on my Windows machine but working on my Mac :)

samvloeberghs commented 8 years ago

voila : https://github.com/massick/gulp-strip-code/pull/2

massick commented 8 years ago

well done! merged and published (to npm too)