Sha256: bc833082da61b71325fc7ec23594fc3e803e660eb35597db11061628941a8b6c

Contents?: true

Size: 997 Bytes

Versions: 2

Compression:

Stored size: 997 Bytes

Contents

'use strict';

var fs   = require('fs');
var path = require('path');

module.exports = function () {
  var packageVersion = require('../package.json').version;
  var output         = [packageVersion];
  var gitPath        = path.join(__dirname,'..','.git');
  var headFilePath   = path.join(gitPath, 'HEAD');

  if (packageVersion.indexOf('+') > -1) {
    try {
      if (fs.existsSync(headFilePath)) {
        var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});
        var branchName = headFile.split('/').slice(-1)[0].trim();
        var refPath = headFile.split(' ')[1];
        var branchSHA;

        if (refPath) {
          var branchPath = path.join(gitPath, refPath.trim());
          branchSHA  = fs.readFileSync(branchPath);
        } else {
          branchSHA = branchName;
        }

        output.push(branchSHA.slice(0,10));
      }
    } catch (err) {
      console.error(err.stack);
    }
    return output.join('.');
  } else {
    return packageVersion;
  }
};

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spider-src-0.1.7 lib/spider-src/support/spider/node_modules/traceur/node_modules/rsvp/lib/calculateVersion.js
spider-src-0.1.6 lib/spider-src/support/spider/node_modules/spider-script/node_modules/traceur/node_modules/rsvp/lib/calculateVersion.js