Skip to content

Commit

Permalink
Merge pull request #11 from enb-bem/windows-fix
Browse files Browse the repository at this point in the history
Fix 'BEMJSON_JS_CODE_REGEXP' for Windows OS
  • Loading branch information
Andrew Abramov committed Dec 3, 2014
2 parents d799c5e + 0af5200 commit 46d4f5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/plugins/inline-bemjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var path = require('path'),
vow = require('vow'),
vfs = require('enb/lib/fs/async-fs'),
scanner = require('enb-bem-pseudo-levels/lib/level-scanner'),
BEMJSON_JS_CODE_REGEX = /`{3,}(bemjson\n[^`]*|js\n\(?(\{|\[)[^`]*block ?:[^`]*(\]|\})\)?)\n`{3,}/gi;
BEMJSON_JS_CODE_REGEX = /`{3,}(bemjson\r?\n[^`]*|js\r?\n\(?(\{|\[)[^`]*block ?:[^`]*(\]|\})\)?)\r?\n`{3,}/gi;

/**
* Возвращает конфигуратор уровня-сетов из примеров БЭМ-блоков с помощью `MagicHelper`.
Expand Down Expand Up @@ -198,13 +198,14 @@ function getExamplesFromMdFile(root, dstpath, filename) {
}

function getExamplesFromSource(source) {
var matched = source.match(BEMJSON_JS_CODE_REGEX);
var lineBreak = path.sep === '/' ? '\n' : '\r\n',
matched = source.match(BEMJSON_JS_CODE_REGEX);

return matched ? matched.map(function (str) {
var code = str.split('\n').slice(1);
var code = str.split(lineBreak).slice(1);

code.pop();
code = code.join('\n');
code = code.join(lineBreak);

var shasum = crypto.createHash('sha1'); shasum.update(code);
var base64 = fixBase64(shasum.digest('base64'));
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/pseudo-levels/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ module.exports = function (options) {
if (hasSublevel || options.fileSuffixes.indexOf(suffix) !== -1) {
res.push({
targetPath: path.join(scope, bemname, file.isDirectory ? basename : basename + SYMLINK_EXT),
sourcePath: file.fullname
sourcePath: file.fullname,
isDirectory: file.isDirectory
});
}
});
Expand Down

0 comments on commit 46d4f5f

Please sign in to comment.