Skip to content

Commit

Permalink
Rename test. Readd indentions
Browse files Browse the repository at this point in the history
  • Loading branch information
faebeee committed Mar 20, 2019
1 parent cfe6de0 commit cbab44d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 7 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const postcss = require('postcss');
const csswring = require('csswring');

module.exports = postcss.plugin('postcss-extract-media-query', opts => {

opts = _.merge({
entry: null,
output: {
Expand Down Expand Up @@ -67,8 +66,8 @@ module.exports = postcss.plugin('postcss-extract-media-query', opts => {
// or otherwise the query key (converted to kebab case)
const hasCustomName = typeof opts.queries[atRule.params] === 'string';
const key = hasCustomName === true
? opts.queries[atRule.params]
: _.kebabCase(atRule.params);
? opts.queries[atRule.params]
: _.kebabCase(atRule.params);

// extract media atRule and concatenate with existing atRule (same key)
// if no whitelist set or if whitelist and atRule has custom query name match
Expand All @@ -83,9 +82,9 @@ module.exports = postcss.plugin('postcss-extract-media-query', opts => {
if (opts.output.path) {

const newFile = opts.output.name
.replace(/\[name\]/g, name)
.replace(/\[query\]/g, key)
.replace(/\[ext\]/g, ext)
.replace(/\[name\]/g, name)
.replace(/\[query\]/g, key)
.replace(/\[ext\]/g, ext)

const newFilePath = path.join(opts.output.path, newFile);

Expand All @@ -98,8 +97,8 @@ module.exports = postcss.plugin('postcss-extract-media-query', opts => {

if (opts.minimize === true) {
const newRootMinimized = postcss([ csswring() ])
.process(newRoot.toString(), { from: newFilePath })
.root;
.process(newRoot.toString(), { from: newFilePath })
.root;
fs.outputFileSync(newFilePath, newRootMinimized.toString());
} else {
fs.outputFileSync(newFilePath, newRoot.toString());
Expand Down
4 changes: 1 addition & 3 deletions test/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ describe('Options', function() {
assert.isTrue(fs.existsSync('test/output/example-screen-and-min-width-1024-px.css'));
assert.isTrue(fs.existsSync('test/output/example-screen-and-min-width-1200-px.css'));
});

it('output.name should affect emited filenames', function() {
const opts = {
output: {
Expand All @@ -81,8 +80,7 @@ describe('Options', function() {
assert.isTrue(fs.existsSync('test/output/screen-and-min-width-1024-px.css'));
assert.isTrue(fs.existsSync('test/output/screen-and-min-width-1200-px.css'));
});

it('output.name can have the same variable multiple times', function () {
it('output.name should support using the same placeholder multiple times', function () {
const opts = {
output: {
path: path.join(__dirname, 'output'),
Expand Down

0 comments on commit cbab44d

Please sign in to comment.