Skip to content

Instantly share code, notes, and snippets.

@henrahmagix
Last active August 24, 2018 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrahmagix/2307fd03410fec17f43206f74e9d1096 to your computer and use it in GitHub Desktop.
Save henrahmagix/2307fd03410fec17f43206f74e9d1096 to your computer and use it in GitHub Desktop.
Order logs from Google Cloudbuild bookmark (copy-paste into new bookmark, click to run)
javascript:(function (el) { if (!el) { throw new Error('no el'); } var text = el.innerText; if (!text) { throw new Error('no text for', el); } var rAll = /Step #(\d+)/; var match = function (s, r) { var m = s.match(r); return m && m[1]; }; var steps = {}; var lines = []; text.split('\n').forEach(s => { var m = match(s, rAll); if (!m) { lines.push(s); } else if (!steps[m]) { steps[m] = [s]; } else { steps[m].push(s); } }); Object.keys(steps).map(ns => parseInt(ns, 10)).sort((a,b) => a-b).forEach(n => { lines.push(steps[n].join('\n')) }); el.innerText = lines.join('\n'); })(document.querySelector('pre'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment