Skip to content

Commit

Permalink
refactor semver parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Apr 25, 2018
1 parent c472253 commit e7c2773
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 3 additions & 5 deletions website/gatherDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const fs = require("fs-extra");
const git = require("nodegit");
const execSync = require('child_process').execSync;
const { major } = require("semver");
const REPO_URL = "https://github.com/wix/detox.git"

// From https://gist.github.com/joerx/3296d972735adc5b4ec1
Expand All @@ -11,17 +12,14 @@ function clearRequireCache() {
});
}

function getMajorVersion(tag) {
return parseInt(tag.split('.')[0], 10)
}

async function getVersions() {
const tmp = fs.mkdtempSync('detox-versions');
const repo = await git.Clone(REPO_URL, tmp);
const tags = await git.Tag.list(repo);

const semverTags = tags
.filter(tag => tag.split('.').length === 3 && getMajorVersion(tag) >= 6)
.filter(tag => !tag.includes("@"))
.filter(tag => tag.split(".").length === 3 && major(tag) >= 6)
.sort()
.reverse();
await fs.remove(tmp);
Expand Down
3 changes: 2 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"dependencies": {
"fs-extra": "^5.0.0",
"nodegit": "^0.21.0"
"nodegit": "^0.21.0",
"semver": "^5.5.0"
}
}

0 comments on commit e7c2773

Please sign in to comment.