Skip to content

Commit

Permalink
fix cache issue in levels-to-bemdecl tech
Browse files Browse the repository at this point in the history
  • Loading branch information
L0stSoul committed Aug 24, 2016
1 parent a877bed commit 049f51a
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions techs/levels-to-bemdecl.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,31 @@ module.exports = inherit(BaseTech, {
cache = node.getNodeCache(target);

return node.requireSources([this._source]).spread(function (introspection) {
if (cache.needRebuildFile('bemdecl-file', bemdeclFilename)) {
var resDeps = introspection.getEntities().map(function (entity) {
var dep = {
block: entity.block
};
var resDeps = introspection.getEntities().map(function (entity) {
var dep = {
block: entity.block
};

entity.elem && (dep.elem = entity.elem);
entity.modName && (dep.mod = entity.modName);
entity.modVal && (dep.val = entity.modVal);
entity.elem && (dep.elem = entity.elem);
entity.modName && (dep.mod = entity.modName);
entity.modVal && (dep.val = entity.modVal);

return dep;
}),
data,
str;
return dep;
}),
data,
str;

if (bemdeclFormat === 'deps') {
data = { deps: resDeps };
str = 'exports.deps = ' + JSON.stringify(resDeps, null, 4) + ';\n';
} else {
var decl = deps.toBemdecl(resDeps);
if (bemdeclFormat === 'deps') {
data = { deps: resDeps };
str = 'exports.deps = ' + JSON.stringify(resDeps, null, 4) + ';\n';
} else {
var decl = deps.toBemdecl(resDeps);

data = { blocks: decl };
str = 'exports.blocks = ' + JSON.stringify(decl, null, 4) + ';\n';
}
data = { blocks: decl };
str = 'exports.blocks = ' + JSON.stringify(decl, null, 4) + ';\n';
}

return vfs.write(bemdeclFilename, str, 'utf8')
.then(function () {
cache.cacheFileInfo('bemdecl-file', bemdeclFilename);
node.resolveTarget(target, data);
});
} else {
if (cache.get('bemdecl') === str) {
node.isValidTarget(target);
clearRequire(bemdeclFilename);

Expand All @@ -99,6 +93,12 @@ module.exports = inherit(BaseTech, {
return null;
});
}

return vfs.write(bemdeclFilename, str, 'utf8')
.then(function () {
cache.set('bemdecl', str);
node.resolveTarget(target, data);
});
});
}
});

0 comments on commit 049f51a

Please sign in to comment.