plugin-set-options-v2.js 715 B

12345678910111213141516171819202122232425262728293031323334
  1. var optionsStack = [
  2. 'option1',
  3. undefined,
  4. 'option2',
  5. undefined,
  6. 'option3'
  7. ];
  8. var optionsWereSet = false;
  9. var options, error;
  10. registerPlugin({
  11. install: function(less, pluginManager, functions) {
  12. if (!optionsWereSet) {
  13. error = 'setOptions() not called before install';
  14. }
  15. },
  16. use: function() {
  17. var pos = optionsStack.indexOf(options);
  18. if (pos === -1) {
  19. error = 'setOptions() not setting option "' + opt + '" correctly';
  20. }
  21. if (error) {
  22. throw new Error(error);
  23. }
  24. },
  25. setOptions: function(opts) {
  26. optionsWereSet = true;
  27. options = opts;
  28. },
  29. minVersion: [2,0,0]
  30. });