-
Notifications
You must be signed in to change notification settings - Fork 2
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
#9 API changes for File and Utils modules #10
Conversation
* @param {Boolean} inlineSourceMap - set to true to add source map code to content | ||
* @returns {string} | ||
*/ | ||
render: function (inlineSourceMap) { |
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.
Лучше сделать объек опций options
, с полем includeComment
.
includeComment: 'inline' | true
— добавит однострочный коментарий// ...
.includeComment: 'block'
— добавит многострочный коментарий/* ... */
.
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.
И если вызвать file.render()
без аргументов, то возвращается { contents, map }
и в contents
не добавляется коментарий.
🆙 |
@@ -16,7 +17,8 @@ describe('File', function () { | |||
it('should add a new line to the output', function () { | |||
file.writeLine('line 1'); | |||
file.writeLine('line 2'); | |||
file.render().should.equal('line 1\nline 2\n'); | |||
file.render().contents.should.equal('line 1\nline 2\n'); | |||
expect(file.render().map).to.be.equal(null); |
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.
Зачем проверять то, что поле с картой пустое?
🆙 |
var content = this._content.join(os.EOL); | ||
var sourceMap = null; |
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.
Кажется, что это не совсем ок, потому что null
и undefined
это не одно и тоже.
Если кто-то будет проверять через typeof
, то у него не получится.
typeof res.map === 'undefined'
Я бы оставил просто var sourceMap;
.
Да, вопрос хороший. @blond что скажешь?
Кажется, что прикольно иметь единый возвращаемый тип данных
Ошибся в jsdoc |
🆙 |
Есть такое предложение: не добавлять функциональности в |
} | ||
return content; | ||
return { | ||
contents: contents, |
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.
а почему, действительно, contents
, а не content
?
C Антоном согласен. |
🆙 |
Сделал не геттерами в их строгом понимании а псевдогеттерами потому что:
|
|
Ок, мне переделать или оставить как есть? |
getContent: function () { | ||
return this._content.join(os.EOL); | ||
}, | ||
|
||
render: function () { | ||
var content = this._content.join(os.EOL); |
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.
вот здесь вполне можно заюзать getContent
|
||
file.render(); | ||
file.render({ includeComment: 'block' }); |
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.
забыл убрать
нужно почистить мусор от предыдущей реализации и поправить тесты: везде, где раньше использовался |
🆙 |
} | ||
return content; | ||
return this._map ? | ||
utils.joinContentAndSourceMap(this.getContent(), this._map, this._opts) : this.getContent(); |
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.
лучше длинные выражения разносить так:
return this._map
? utils.joinCon...
: this.getContent();
🆙 |
@@ -164,7 +162,7 @@ describe('File', function () { | |||
|
|||
file.writeFileContent('some-file.js', middleContent); | |||
|
|||
var pos = utils.getSourceMap(file.render()).originalPositionFor({line: 1, column: 0}); | |||
var pos = getOriginalSourceMapPosition(file.getSourceMap()); |
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.
блин, андрюха, ты издеваешься? ) саму позицию-то ты зачем унес в хелпер?
Должно быть как-то так:
var pos = getOriginalPositionFor({line: 1, column: 0}, file.getSourceMap());
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.
Нет, не издеваюсь
Во всех случаях использования были именно такие аргументы которые указывают на начальную позицию.
Здесь лишь разумный компромисс между гибкостью использования хелпера и размером копипаста
в остальном 🆗 |
Поправил последнее замечание P.S. кстати, несмотря на наличие travis.yml конфигурационного файла, что-то я не вижу P.S. Нужно будет выпустить обновленную версию enb-source-map |
Так, стоп. Я тут попробовал использовать изменения которые мы внесли и обнаружил, что не все ок. Но Нужно чтобы |
Реализовал в последнем коммите. Проверил для enb-diverse-js. Все ок. |
я ж тебя об этом спрашивал |
Ну лучше поздно, чем никогда. P.S. Наверное можно мержить и выпускать версию |
👍 |
А давайте перед выпуском обновим зависимости? А то |
а давайте зависимости отдельным PR |
|
#9 API changes for File and Utils modules
Resolved #9
Needs for enb/enb-js#12
@j0tunn @blond
Please review it