chalk.js 326 B

123456789101112131415161718
  1. 'use strict';
  2. const Chalk = require('chalk').constructor;
  3. let ctx = null;
  4. exports.get = () => {
  5. if (!ctx) {
  6. throw new Error('Chalk has not yet been configured');
  7. }
  8. return ctx;
  9. };
  10. exports.set = options => {
  11. if (ctx) {
  12. throw new Error('Chalk has already been configured');
  13. }
  14. ctx = new Chalk(options);
  15. return ctx;
  16. };