Revision 4da45df4dc3ac25061731e83afc76c9970029794 authored by Andreas Stuhlmüller on 02 July 2017, 20:13:26 UTC, committed by GitHub on 02 July 2017, 20:13:26 UTC
More sample/dist arg checks
store.js
'use strict';
var estraverse = require('estraverse');
var Syntax = estraverse.Syntax;
var build = require('ast-types').builders;
var isPrimitive = require('../syntax').isPrimitive;
var storeIdNode = build.identifier('globalStore');
function store(node) {
switch (node.type) {
// have to add the store argument to each function
case Syntax.FunctionExpression:
return build.functionExpression(node.id,
[storeIdNode].concat(node.params),
node.body);
// pass the store variable at each call (that isn't primitive)
case Syntax.CallExpression:
if (isPrimitive(node.callee)) {
return node;
}
else if (node.arguments.length > 0 &&
node.arguments[0].type === 'Identifier' &&
node.arguments[0].name === 'globalStore') {
return node;
}
else {
return build.callExpression(node.callee,
[storeIdNode].concat(node.arguments));
}
default:
return node;
}
}
function storeMain(node) {
return estraverse.replace(node, {leave: store});
}
module.exports = {
store: storeMain
};
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...