gulp-order-bemdeps
Advanced tools
Comparing version 0.1.0 to 0.1.1
36
index.js
@@ -47,11 +47,11 @@ 'use strict'; | ||
if (dependency.mod) { | ||
dependencyStem += `_${dependency.mod}`; | ||
dependencyStem += `_${ dependency.mod }`; | ||
} | ||
if (dependency.val) { | ||
dependencyStem += `_${dependency.val}`; | ||
dependencyStem += `_${ dependency.val }`; | ||
} | ||
if (dependency.elem) { | ||
dependencyStem += `__${dependency.elem}`; | ||
dependencyStem += `__${ dependency.elem }`; | ||
} | ||
@@ -103,3 +103,3 @@ | ||
// therefore it must depend on block__elem | ||
basicDependencies.push(`${dataChunk.bemNaming.block}__${dataChunk.bemNaming.elem}`); | ||
basicDependencies.push(`${ dataChunk.bemNaming.block }__${ dataChunk.bemNaming.elem }`); | ||
} | ||
@@ -111,5 +111,5 @@ | ||
if (dataChunk.bemNaming.modVal) { | ||
basicDependencies.push(`${dataChunk.bemNaming.block}_${dataChunk.bemNaming.mod}_${dataChunk.bemNaming.modVal}`); | ||
basicDependencies.push(`${ dataChunk.bemNaming.block }_${ dataChunk.bemNaming.mod }_${ dataChunk.bemNaming.modVal }`); | ||
} else { | ||
basicDependencies.push(`${dataChunk.bemNaming.block}_${dataChunk.bemNaming.mod}`); | ||
basicDependencies.push(`${ dataChunk.bemNaming.block }_${ dataChunk.bemNaming.mod }`); | ||
} | ||
@@ -124,3 +124,3 @@ } | ||
return new Promise(resolve => { | ||
fs.readFile(dataChunk.file, {encoding: 'utf8'}, (err, contents) => { | ||
fs.readFile(dataChunk.file, { encoding: 'utf8' }, (err, contents) => { | ||
let deps; | ||
@@ -148,2 +148,4 @@ | ||
function getNodeDepth(rawDeps, stem, base) { | ||
var _Math; | ||
base = base || 0; | ||
@@ -165,3 +167,3 @@ | ||
return Math.max(...dependenciesDepth); | ||
return (_Math = Math).max.apply(_Math, dependenciesDepth); | ||
} | ||
@@ -186,3 +188,3 @@ | ||
return knownDepthNodes.sort((a, b) => { | ||
return (a.depth - b.depth) || a.stem.localeCompare(b.stem); | ||
return a.depth - b.depth || a.stem.localeCompare(b.stem); | ||
}).map(node => node.stem); | ||
@@ -197,3 +199,3 @@ } | ||
*/ | ||
function * iterateList(ctx, list) { | ||
function* iterateList(ctx, list) { | ||
for (let stem of list) { | ||
@@ -222,3 +224,3 @@ let filesList = ctx[BEM_NAMING_KEY].get(stem); | ||
if (isBadNaming) { | ||
throw new PluginError(PLUGIN_NAME, `Invalid bem naming used: ${fileStem}`); | ||
throw new PluginError(PLUGIN_NAME, `Invalid bem naming used: ${ fileStem }`); | ||
} | ||
@@ -241,3 +243,3 @@ | ||
glob(`${base}/**/*.deps.js`, (err, deps) => { | ||
glob(`${ base }/**/*.deps.js`, (err, deps) => { | ||
if (err) { | ||
@@ -271,3 +273,3 @@ reject(err); | ||
if (isBadNaming) { | ||
reject(new Error(`Invalid bem naming used: ${stem}`)); | ||
reject(new Error(`Invalid bem naming used: ${ stem }`)); | ||
return; | ||
@@ -277,3 +279,3 @@ } | ||
let stemFiles = stems.get(stem) || []; | ||
stemFiles.push({file: file, bemNaming: bemNaming}); | ||
stemFiles.push({ file: file, bemNaming: bemNaming }); | ||
stems.set(stem, stemFiles); | ||
@@ -310,4 +312,4 @@ } | ||
for (let file of iterateList(this, tree)) { | ||
let header = new Buffer(`/* ${file.path}: begin */\n`); | ||
let footer = new Buffer(`/* ${file.path}: end */\n`); | ||
let header = new Buffer(`/* ${ file.path }: begin */\n`); | ||
let footer = new Buffer(`/* ${ file.path }: end */\n`); | ||
file.contents = Buffer.concat([header, file.contents, footer]); | ||
@@ -320,3 +322,3 @@ | ||
}).catch(err => { | ||
throw new PluginError(PLUGIN_NAME, `Dependency tree build fail: ${err.message}`, {showStack: true}); | ||
throw new PluginError(PLUGIN_NAME, `Dependency tree build fail: ${ err.message }`, { showStack: true }); | ||
}); | ||
@@ -323,0 +325,0 @@ } |
{ | ||
"name": "gulp-order-bemdeps", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Reorder a stream of files using deps.js files contents", | ||
@@ -26,5 +26,7 @@ "bugs": { | ||
"engines": { | ||
"node": ">=5.0" | ||
"node": ">=4.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "6.1.2", | ||
"babel-plugin-transform-es2015-spread": "6.0.14", | ||
"jscs": "2.5.0", | ||
@@ -34,4 +36,5 @@ "jshint": "2.8.0" | ||
"scripts": { | ||
"lint": "./node_modules/.bin/jshint -c .jshintrc index.js && ./node_modules/.bin/jscs -c .jscsrc index.js" | ||
"lint": "./node_modules/.bin/jshint -c .jshintrc index.js && ./node_modules/.bin/jscs -c .jscsrc index.js", | ||
"prepublish": "./node_modules/.bin/babel --plugins=babel-plugin-transform-es2015-spread index.js --out-file index.js" | ||
} | ||
} |
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
19421
9
262
4