Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles ⚡ committed Aug 4, 2018
1 parent b54f770 commit 2567996
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
28 changes: 28 additions & 0 deletions postcss-parker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const postcss = require('postcss');
const fs = require('fs');
const Parker = require('parker/lib/Parker');
const metrics = require('parker/metrics/All');
const format = require('json-format');

let defaultOptions = {
outputFile: './parker.json'
};

module.exports = postcss.plugin('postcss-parker', options => {
let opts = Object.assign({}, defaultOptions, options);

return function(root, result) {
let reporter = new Parker(metrics);

const { css } = root.toResult();

let results = reporter.run(css);

let output = format(results, { type: 'space', size: 2 });

fs.writeFile(opts.outputFile, output, err => {
if (err) throw err;
console.log('The file has been saved!');
});
};
});
10 changes: 10 additions & 0 deletions postcss-parker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "postcss-parker",
"version": "0.1.0",
"main": "index.js",
"dependencies": {
"json-format": "^1.0.1",
"parker": "^0.0.10",
"postcss": "^7.0.2"
}
}

0 comments on commit 2567996

Please sign in to comment.