gulp-bem-project
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -0,1 +1,5 @@ | ||
## 0.6.0 | ||
* **new**: `wrap-with-path` plugin now supports stream based vinyl files | ||
## 0.5.1 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "gulp-bem-project", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "Gulp plugins for modern BEM projects", | ||
@@ -37,4 +37,4 @@ "bugs": { | ||
"lint": "./node_modules/.bin/jshint -c .jshintrc index.js && ./node_modules/.bin/jscs -c .jscsrc index.js", | ||
"test": "./node_modules/.bin/mocha -R spec --timeout 10000 --slow 5000 test/" | ||
"test": "./node_modules/.bin/mocha -R spec --timeout 10000 --slow 5000 test/**/*.js test/*.js" | ||
} | ||
} |
@@ -6,5 +6,30 @@ 'use strict'; | ||
const PLUGIN_NAME = 'gulp-bem-project => wrap-with-path'; | ||
function getPrefixString(filePath) { | ||
return `/* begin: ${filePath} */\n`; | ||
} | ||
function getPostfixString(filePath) { | ||
return `/* end: ${filePath} */\n`; | ||
} | ||
/** | ||
* Wraps file content stream with prefix and postfix | ||
* | ||
* @param {Vinyl} file | ||
* @return {Stream} | ||
*/ | ||
function wrapFileContentsStream(file) { | ||
const outputStream = through2(); | ||
outputStream.write(getPrefixString(file.path)); | ||
file.contents.pipe(outputStream); | ||
process.nextTick(() => { | ||
outputStream.write(getPostfixString(file.path)); | ||
}); | ||
return outputStream; | ||
} | ||
/** | ||
* Wraps file contents with comments with file path | ||
@@ -22,12 +47,11 @@ * | ||
if (file.isStream()) { | ||
callback(new gutil.PluginError(PLUGIN_NAME, 'Streaming is not supported')); | ||
return; | ||
file.contents = wrapFileContentsStream(file); | ||
} else { | ||
file.contents = Buffer.concat([ | ||
new Buffer(getPrefixString(file.path)), | ||
file.contents, | ||
new Buffer(getPostfixString(file.path)) | ||
]); | ||
} | ||
file.contents = Buffer.concat([ | ||
new Buffer(`/* begin: ${file.path} */\n`), | ||
file.contents, | ||
new Buffer(`/* end: ${file.path} */\n`) | ||
]); | ||
this.push(file); | ||
@@ -34,0 +58,0 @@ callback(); |
Sorry, the diff of this file is not supported yet
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
13287
12
214