项目原始demo,不改动
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
Questo repository è archiviato. Puoi vedere i file e clonarli, ma non puoi effettuare richieste di pushj o aprire problemi/richieste di pull.
 
 
 
 

36 righe
871 B

  1. 'use strict';
  2. var _ = require('lodash');
  3. /**
  4. * Choice object
  5. * Normalize input as choice object
  6. * @constructor
  7. * @param {String|Object} val Choice value. If an object is passed, it should contains
  8. * at least one of `value` or `name` property
  9. */
  10. var Choice = module.exports = function (val, answers) {
  11. // Don't process Choice and Separator object
  12. if (val instanceof Choice || val.type === 'separator') {
  13. return val;
  14. }
  15. if (_.isString(val)) {
  16. this.name = val;
  17. this.value = val;
  18. this.short = val;
  19. } else {
  20. _.extend(this, val, {
  21. name: val.name || val.value,
  22. value: 'value' in val ? val.value : val.name,
  23. short: val.short || val.name || val.value
  24. });
  25. }
  26. if (_.isFunction(val.disabled)) {
  27. this.disabled = val.disabled(answers);
  28. } else {
  29. this.disabled = val.disabled;
  30. }
  31. };