Created
September 28, 2021 10:08
-
-
Save bantic/66f6c77bf878abb2e3a50f70848b539e to your computer and use it in GitHub Desktop.
Revisions
-
bantic created this gist
Sep 28, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ #!/usr/bin/env zx $.verbose = false; const MAX_v2_MINOR = 18; let version = { major: 3, minor: 28, patch: 0 }; version.toString = function () { return `v${this.major}.${this.minor}.${this.patch}`; }; version.decrementMinor = function () { if (this.minor > 0) { this.minor -= 1; } else { if (this.major === 3) { this.major = 2; this.minor = MAX_v2_MINOR; } else { throw new Error(`Cannot decrement: ${version}`); } } }; async function tagExists(version) { try { let result = await $`git tag -l ${version}`; return true; } catch (p) { return p.exitCode === 0; } } async function checkForString(string, filepath, tag) { await $`git checkout ${tag}`; if (!fs.existsSync(filepath)) { throw new Error(`path ${filepath} doesn't exist`); } try { await $`cat ${filepath} | grep ${string}`; return true; } catch (p) { return p.exitCode === 0; } } while (true) { console.log(`Checking Version: ${version}`); let exists = await tagExists(version); if (!exists) { console.log(`Skipping version ${version}`); } else { let str = "index("; let filepath = "lib/broccoli/ember-app.js"; let isFound = await checkForString(str, filepath, version.toString()); if (isFound) { console.log(`FOUND! "${str}" at ${filepath} for version ${version}`); } } version.decrementMinor(); }