All files / style9 babel.js

100% Statements 10/10
100% Branches 2/2
100% Functions 2/2
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 208x 8x   8x 84x       84x   83x 83x   83x 69x          
const NAME = require('./package.json').name;
const processReferences = require('./src/process-references.js');
 
module.exports = function style9BabelPlugin() {
  return {
    name: NAME,
    visitor: {
      ImportDefaultSpecifier(path, state) {
        if (path.parent.source.value !== NAME) return;
 
        const importName = path.node.local.name;
        const bindings = path.scope.bindings[importName].referencePaths;
 
        const css = processReferences(bindings, state.opts).join('');
        state.file.metadata.style9 = css;
      }
    }
  };
};