-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed mock-lang-js
tech
#100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
var vfs = require('enb/lib/fs/async-fs'); | ||
var vfs = require('enb/lib/fs/async-fs'), | ||
File = require('enb-source-map/lib/file'), | ||
EOL = require('os').EOL; | ||
|
||
module.exports = require('enb/lib/build-flow').create() | ||
.name('mock-lang-js.js') | ||
.target('target', '?.js') | ||
.useSourceFilename('source', '?.lang.js') | ||
.builder(function (source) { | ||
return vfs.read(source, 'utf8') | ||
.then(function (content) { | ||
var mock = [ | ||
.builder(function (sourceFilename) { | ||
return vfs.read(sourceFilename, 'utf8') | ||
.then(function (contents) { | ||
var withSourceMaps = true, | ||
file = new File(this._target, withSourceMaps), | ||
mock = [ | ||
';(function(global, bem_) {', | ||
' global.BEM = bem_;', | ||
' var i18n = bem_.I18N = function(keyset, key, param) {', | ||
|
@@ -21,20 +25,12 @@ module.exports = require('enb/lib/build-flow').create() | |
' i18n.key = function(key) { return key }', | ||
' i18n.lang = function() { return }', | ||
'}(this, typeof BEM === \'undefined\' ? {} : BEM));' | ||
].join('\n'), | ||
mapIndex = content.lastIndexOf('//# sourceMappingURL='), | ||
map; | ||
].join(EOL); | ||
|
||
// if there is a #sourceMappingURL pragma append | ||
// the mock before it so the source map will be | ||
// valid. We can't insert it in the beginning because | ||
// source map locations will point to the wrong lines. | ||
if (mapIndex !== -1) { | ||
map = content.substring(mapIndex); | ||
content = content.substring(0, mapIndex); | ||
} | ||
file.write(mock); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Этот вызов пишет в файл или просто кудато в память складывает? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В память инстанса. Если потом позвать |
||
file.writeFileContent(sourceFilename, contents); | ||
|
||
return [content, mock, map].join('\n'); | ||
return file.render(); | ||
}); | ||
}) | ||
.createTech(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Используется в одном месте. Просто передать true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В одном месте, просто чтобы читалось лучше.