How to use the js-git/lib/modes.js.file function in js-git

To help you get started, we’ve selected a few js-git examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github creationix / tedit / src / data / publisher.js View on Github external
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);
      }
github creationix / tedit / src / git-tree.js View on Github external
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 = {};
github creationix / tedit / src / ui / tree.js View on Github external
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
    });
  });
}
github creationix / tedit / src / ui / tree.js View on Github external
row.call(fs.saveAs, "blob", "", function (hash) {
      addChild(row, name, modes.file, hash);
    });
  });
github creationix / tedit / src / ui / row.js View on Github external
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) {