-
Notifications
You must be signed in to change notification settings - Fork 54
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
Do not build graph by default #357
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
"maxlen": 120, | ||
"unused": true, | ||
"undef": true, | ||
"node": true | ||
"node": true, | ||
"laxbreak": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var Node = require('./node'); | ||
var NodeWithGraph = require('./node-with-graph'); | ||
|
||
exports.mkNode = function (nodePath, makePlatform, cache, graph) { | ||
return graph | ||
? new NodeWithGraph(nodePath, makePlatform, cache, graph) | ||
: new Node(nodePath, makePlatform, cache); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* NodeWithGraph | ||
* ============= | ||
*/ | ||
|
||
var Node = require('./node'); | ||
var Vow = require('vow'); | ||
var inherit = require('inherit'); | ||
var path = require('path'); | ||
var _ = require('lodash'); | ||
|
||
module.exports = inherit(Node, { | ||
__constructor: function (nodePath, makePlatform, cache, graph) { | ||
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. туда собственно передается граф из makePlatform 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. Потому что объект класса |
||
this.__base(nodePath, makePlatform, cache); | ||
|
||
/** | ||
* Построитель графа сборки. | ||
* @type {BuildGraph} | ||
* @name NodeWithGraph.prototype._graph | ||
* @private | ||
*/ | ||
this._graph = graph; | ||
}, | ||
|
||
/// | ||
_initTech: function (tech) { | ||
var _this = this; | ||
var nodeAdapterClass = function () {}; | ||
nodeAdapterClass.prototype = _this; | ||
var nodeAdapter = new nodeAdapterClass(); | ||
|
||
return Vow.when(tech.init(nodeAdapter)).then(function () { | ||
return Vow.when(tech.getTargets()).then(function (targets) { | ||
targets.forEach(function (target) { | ||
var targetPath = path.join(_this._path, target); | ||
_this._graph.addTarget(targetPath, tech.getName()); | ||
}); | ||
|
||
nodeAdapter.requireSources = function (sources) { | ||
return _this.requireSources(sources, targets); | ||
}; | ||
nodeAdapter.requireNodeSources = function (sources) { | ||
return _this.requireNodeSources(sources, targets); | ||
}; | ||
}); | ||
}); | ||
}, | ||
|
||
/// | ||
requireSources: function (sources, targets) { | ||
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. В этом и смысл: это отдельный класс, в котором 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. как это не нужен? Он же из makePlatform летит, и в конструкторе сохраняется в свойство |
||
var _this = this; | ||
this._addDepsToGraph(targets, sources, function (source) { | ||
return path.join(_this._path, _this.unmaskTargetName(source)); | ||
}); | ||
|
||
return Node.prototype.requireSources.apply(this, arguments); | ||
}, | ||
|
||
/// | ||
requireNodeSources: function (sources, targets) { | ||
var _this = this; | ||
_.forEach(sources, function (nodeSources, nodeName) { | ||
_this._addDepsToGraph(targets, nodeSources, function (source) { | ||
return path.join(nodeName, _this.unmaskNodeTargetName(nodeName, source)); | ||
}); | ||
}); | ||
|
||
return Node.prototype.requireNodeSources.apply(this, arguments); | ||
}, | ||
|
||
/// | ||
_addDepsToGraph: function (targets, sources, getDepFromPath) { | ||
var _this = this; | ||
targets = targets || []; | ||
|
||
targets.forEach(function (target) { | ||
var targetPath = path.join(_this._path, target); | ||
sources.forEach(function (source) { | ||
_this._graph.addDep( | ||
targetPath, | ||
getDepFromPath(source) | ||
); | ||
}); | ||
}); | ||
}, | ||
|
||
/// | ||
resolveTarget: function (target) { | ||
this._graph.resolveTarget(path.join(this._path, target)); | ||
return Node.prototype.resolveTarget.apply(this, arguments); | ||
}, | ||
|
||
/// | ||
destruct: function () { | ||
this.__base(); | ||
delete this._graph; | ||
} | ||
}); |
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.
Сокращения - зло. Почему не
buildNode
?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.
Это явно не build, но сокращения зло :)
По мне —
createNode
.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.
Почему не
build
?factory.buildNode(params);
- вполне себе фабрика нод строит ноду.create
- тоже ок.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.
Распространенные, общеизвестные сокращения - благо. Никто ж не жалуется на
mkdir
или собственно наdir
. Или кто-то из вас не понял что означает сие сокращение?Может еще
API
не будем использовать? Илиimg
? Илиptr
в плюсах?Давайте руководствоваться здравым смыслом, а не громкими лозунгами
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.
С пониманием 🆗 Спотыкаешься, когда читаешь - ведь проще прочитать
copyString
, чемstrcpy
.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.
дело привычки