Skip to content

Commit

Permalink
fix file regex (#10)
Browse files Browse the repository at this point in the history
* Fix: adjust filename regex

This makes sure dot namespaced filenames are working, too.

* Fix: adjust text to also check namespace support
  • Loading branch information
SassNinja authored Jun 21, 2019
1 parent 8bedd3b commit d70d45f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ module.exports = postcss.plugin('postcss-extract-media-query', opts => {
from = result.opts.from;
}

const file = from.match(/[^/\\]+\.\w+$/)[0].split('.');
const name = file[0];
const ext = file[1];
const file = from.match(/([^/\\]+)\.(\w+)(?:\?.+)?$/);
const name = file[1];
const ext = file[2];

const newAtRules = {};

Expand Down
3 changes: 3 additions & 0 deletions test/data/entry-example.namespace.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@media screen {
.foo { color: blue; }
}
4 changes: 2 additions & 2 deletions test/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ describe('Options', function() {
describe('entry', function() {
it('entry should override any other from option', function() {
const opts = {
entry: path.join(__dirname, 'data/entry-example.css'),
entry: path.join(__dirname, 'data/entry-example.namespace.css'),
output: {
path: path.join(__dirname, 'output')
},
stats: false
};
postcss([ plugin(opts) ]).process(entryExampleFile, { from: 'test/data/example.css'}).css;
assert.isTrue(fs.existsSync('test/output/entry-example-screen.css'));
assert.isTrue(fs.existsSync('test/output/entry-example.namespace-screen.css'));
});
});

Expand Down

0 comments on commit d70d45f

Please sign in to comment.