Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function bake(req, callback) {
req.ruleHash = sha1(JSON.stringify(req));
// console.log("BAKE", {
// req: req,
// settings: settings
// });
if (!settings.filters) {
// TODO: serve rule file as static file.
return callback(null, {mode:modes.file,hash:"TODO:servefile",fetch:function (callback) {
callback(null, binary.fromUnicode("TODO:servefile"));
}});
}
var codeHash;
var codePath = pathJoin(settings.filters, req.program + ".js");
return servePath(codePath, onCodeEntry);
function onCodeEntry(err, entry) {
if (err) return callback(err);
if (!entry.hash) return callback(new Error("Missing filter " + req.name));
req.codeHash = codeHash = entry.hash;
// If the code hasn't changed, reuse the existing compiled worker.
if (codeHashes[req.program] === codeHash) {
return filters[req.program](servePath, req, callback);
}
changeNames.forEach(function (root) {
var meta = pendingChanges[root].meta;
var path = join(root, ".gitmodules");
var encoded = codec.encode(meta);
if (!encoded.trim()) {
// Delete the file if it's now empty
writes[path] = {};
}
else {
writes[path] = {
mode: modes.file,
content: encoded
};
}
});
pendingChanges = {};
function toggleExec(row) {
var newMode = row.mode === modes.exec ? modes.file : modes.exec;
row.call(fs.readEntry, function (entry) {
row.call(fs.writeEntry, {
mode: row.mode = newMode,
hash: entry.hash
});
});
}
function toggleExec(row) {
var newMode = row.mode === modes.exec ? modes.file : modes.exec;
row.call(fs.readEntry, function (entry) {
row.call(fs.writeEntry, {
mode: row.mode = newMode,
hash: entry.hash
});
});
}
row.call(fs.saveAs, "blob", "", function (hash) {
addChild(row, name, modes.file, hash);
});
});
function updateIcon() {
var value =
(errorMessage ? "icon-attention" :
busy ? "icon-spin1 animate-spin" :
mode === modes.sym ? "icon-link" :
mode === modes.file ? "icon-doc" :
mode === modes.exec ? "icon-cog" :
mode === modes.commit ? "icon-fork" :
open ? "icon-folder-open" : "icon-folder") +
(mode === modes.commit ? " tight" : "");
$.icon.setAttribute("class", value);
var title = modes.toType(mode) + " " + hash;
if (errorMessage) title += "\n" + errorMessage;
$.icon.setAttribute("title", title);
if (mode !== modes.commit) {
if ($.folder) {
$.row.removeChild($.folder);
delete $.folder;
}
}
else {
if (!$.folder) {
row.call(fs.saveAs, "blob", body, function (hash) {
notify("Adding " + file.name);
addChild(row, file.name, modes.file, hash);
});
};
row.call(fs.saveAs, "blob", "", function (hash) {
addChild(row, name, modes.file, hash);
});
});