Code coverage report for yeoman-generator/lib/actions/user.js

Statements: 100% (18 / 18)      Branches: 100% (4 / 4)      Functions: 100% (2 / 2)      Lines: 100% (18 / 18)      Ignored: none     

All files » yeoman-generator/lib/actions/ » user.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44  9 9   9                 9 9 9     5   5 1     4 4   4       5   5 1     4 4   4      
'use strict';
var shell = require('shelljs');
var _ = require('lodash');
 
var user = module.exports;
 
/**
 * Git related method
 *
 * The value will come from the global scope or the project scope (it'll take
 * what git will use in the current context)
 */
 
var usernameCache = {};
var emailCache = {};
user.git = {
  // current git user.name
  get username() {
    var username = usernameCache[process.cwd()];
 
    if (username) {
      return username;
    }
 
    username = shell.exec('git config --get user.name', { silent: true }).output.trim();
    usernameCache[process.cwd()] = username;
 
    return username;
  },
  // current git user.email
  get email() {
    var email = emailCache[process.cwd()];
 
    if (email) {
      return email;
    }
 
    email = shell.exec('git config --get user.email', { silent: true }).output.trim();
    emailCache[process.cwd()] = email;
 
    return email;
  }
};