"use strict";

var _postcss = _interopRequireDefault(require("postcss"));

var _postcssHashClassname = _interopRequireDefault(require("postcss-hash-classname"));

var _fs = _interopRequireDefault(require("fs"));

var _utils = require("../../utils");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

let count = 0;
const options = (0, _utils.getOptions)();
const {
  classnameFormat
} = options.test;
module.exports = {
  process: function (src) {
    count++;
    const opts = {
      hashType: 'md5',
      digestType: 'base32',
      maxLength: 6,
      type: '.json',
      classnameFormat: classnameFormat,
      outputName: `jsonFile_test_${count}`
    };
    const processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
    processor.process(src).css;

    const jsonMap = _fs.default.readFileSync(`jsonFile_test_${count}.json`, 'UTF-8');

    _fs.default.unlinkSync(`jsonFile_test_${count}.json`);

    return `module.exports =${jsonMap}`;
  }
};