Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getBranches (project, callback) {
const localProject = '/tmp/' + project.name
require('simple-git')(localProject).listRemote(['--heads'], (err, heads) => {
if (!err) {
let output = []
heads.split('\n').forEach(p => {
if (p && p.split('\t')[1].match(/^refs\/heads\//)) {
output.push(p.split('\t')[1].replace(/^refs\/heads\//, ''))
}
})
callback(output)
}
})
}
function getTags (project, callback) {
const localProject = '/tmp/' + project.name
require('simple-git')(localProject).listRemote(['--tags'], (err, tags) => {
if (!err) {
let output = []
tags.split('\n').forEach(p => {
if (p && p.split('\t')[1].match(/^refs\/tags\//)) {
output.push(p.split('\t')[1].replace(/^refs\/tags\//, ''))
}
})
callback(output)
}
})
}
function getCurrentVersion(callback) {
var latestVersion = '3.8';
require('simple-git')().listRemote('--tags '+ wordpressRepo, function(err, tagsList) {
if (err) return callback(err, latestVersion);
tagList = ('' + tagsList).split('\n');
tagList.pop();
lastTag = /\d\.\d(\.\d)?/ig.exec(tagList.pop());
if (lastTag !== null) {
latestVersion = lastTag[0];
}
callback(null, latestVersion);
});
};