diff --git a/index.js b/index.js index 31ed886..48c1026 100644 --- a/index.js +++ b/index.js @@ -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: { @@ -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 @@ -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); @@ -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()); diff --git a/test/options.js b/test/options.js index b564822..ee01a7a 100644 --- a/test/options.js +++ b/test/options.js @@ -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: { @@ -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'),