All files / piscosour/plugins/context index.js

30% Statements 3/10
0% Branches 0/8
0% Functions 0/1
30% Lines 3/10
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    1x 1x   1x                                          
'use strict';
 
const context = require('../../lib/context');
const search = require('../../lib/utils/search');
 
module.exports = {
  check: function() {
    if (!this.params.disableContextCheck && !this.params.isGenerator) {
      let ami = this.ctxWhoami();
      if (this._context && ami.indexOf(this._context) < 0) {
        throw {error: 'This is not the root of a ' + this._context};
      }
      this.logger.trace('Context checked: ' + this._context, '#green', 'OK');
    }
  },
 
  addons: {
    ctxIs(name) {
      return context.cis(name);
    },
    ctxWhoami() {
      return context.whoami();
    },
    searchNpm: search.searchByKeyword
  }
};