新增: - backend/venv/ - Python 虚拟环境 - backend/start.sh - 启动脚本(使用虚拟环境) - backend/requirements.txt - 依赖列表 - .gitignore - 忽略虚拟环境和缓存文件 说明: - 每个项目使用独立虚拟环境 - 避免依赖冲突 - 启动脚本自动创建和激活虚拟环境
39 lines
950 B
JavaScript
39 lines
950 B
JavaScript
var configuration = require('../../configuration');
|
|
|
|
function findComponentIn(shorthand, longhand) {
|
|
var comparator = nameComparator(longhand);
|
|
|
|
return findInDirectComponents(shorthand, comparator) || findInSubComponents(shorthand, comparator);
|
|
}
|
|
|
|
function nameComparator(to) {
|
|
return function(property) {
|
|
return to.name === property.name;
|
|
};
|
|
}
|
|
|
|
function findInDirectComponents(shorthand, comparator) {
|
|
return shorthand.components.filter(comparator)[0];
|
|
}
|
|
|
|
function findInSubComponents(shorthand, comparator) {
|
|
var shorthandComponent;
|
|
var longhandMatch;
|
|
var i, l;
|
|
|
|
if (!configuration[shorthand.name].shorthandComponents) {
|
|
return;
|
|
}
|
|
|
|
for (i = 0, l = shorthand.components.length; i < l; i++) {
|
|
shorthandComponent = shorthand.components[i];
|
|
longhandMatch = findInDirectComponents(shorthandComponent, comparator);
|
|
|
|
if (longhandMatch) {
|
|
return longhandMatch;
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = findComponentIn;
|