only update latest docs if they are actually latest version

This commit is contained in:
Tim Lancina
2015-09-04 15:12:07 -05:00
parent 1589f321d9
commit 2e60bbb722

View File

@@ -36,12 +36,18 @@ module.exports = function(currentVersion){
try {
versions = fs.readdirSync(path.resolve(__dirname, '../../dist/ionic-site/docs'))
.filter(semver.valid)
.sort(semver.rcompare);
} catch(e) {
versions = [];
}
!_.contains(versions, currentVersion) && versions.unshift(currentVersion);
// new version, add it to the versions list
if (currentVersion != 'nightly' && !_.contains(versions, currentVersion)){
versions.unshift(currentVersion);
}
// sort by version so we can find latest
versions.sort(semver.rcompare);
// add nightly if it isn't in the list
!_.contains(versions, 'nightly') && versions.unshift('nightly');
//First semver valid version is latest
@@ -73,11 +79,9 @@ module.exports = function(currentVersion){
// remove filename since we have multiple docTypes per file
docPath = docPath.substring(0, docPath.lastIndexOf('/') + 1);
docPath += doc.name + '/index.md';
var path = 'docs/' + (versionData.current.folder || '') +
'api/' + docPath;
'/api/' + docPath;
// console.log(path);
return path;
}
}];