#!/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(); }