diff --git a/index.js b/index.js index 34aa4ab..fb36e7a 100644 --- a/index.js +++ b/index.js @@ -60,9 +60,7 @@ function getEnvIdFromBranch () { try { let branch = sh.exec('git name-rev HEAD --name-only').stdout - branch = branch.split('/') - - branch = branch[branch.length - 1] + branch = _.last(_.split(branch, '/')) return _.trimEnd(_.truncate(branch, { length: 13, diff --git a/test/_env.js b/test/_env.js index e1636ed..95ea5ab 100644 --- a/test/_env.js +++ b/test/_env.js @@ -6,9 +6,7 @@ const sh = require('shelljs') module.exports = function (regex) { var env = sh.exec('git name-rev HEAD --name-only').stdout - env = env.split('/') - - env = env[env.length - 1] + env = _.last(_.split(env, '/')) return env ? _.truncate(env, { length: 13,