Skip to content

Commit 6553f16

Browse files
authoredApr 12, 2018
Merge pull request #40 from joscha/joscha/postcss
feat: add CSS (PostCSS dialect)
2 parents ab7f601 + 5068a88 commit 6553f16

File tree

6 files changed

+121
-4
lines changed

6 files changed

+121
-4
lines changed
 

‎Readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Supports:
1111
* JavaScript modules: AMD, CommonJS, and ES6.
1212
* Typescript
1313
* CSS Preprocessors: Sass, Stylus, and Less
14+
* CSS (PostCSS)
1415

1516
### Usage
1617

‎index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var detectiveCjs = require('detective-cjs');
66
var detectiveAmd = require('detective-amd');
77
var detectiveEs6 = require('detective-es6');
88
var detectiveLess = require('detective-less');
9+
var detectivePostcss = require('detective-postcss');
910
var detectiveSass = require('detective-sass');
1011
var detectiveScss = require('detective-scss');
1112
var detectiveStylus = require('detective-stylus');
@@ -71,6 +72,9 @@ function precinct(content, options) {
7172
case 'commonjs':
7273
theDetective = mixedMode ? detectiveEs6Cjs : detectiveCjs;
7374
break;
75+
case 'css':
76+
theDetective = detectivePostcss;
77+
break;
7478
case 'amd':
7579
theDetective = detectiveAmd;
7680
break;
@@ -137,7 +141,7 @@ precinct.paperwork = function(filename, options) {
137141
var ext = path.extname(filename);
138142
var type;
139143

140-
if (ext === '.scss' || ext === '.sass' || ext === '.less' || ext === '.ts') {
144+
if (ext === '.css' || ext === '.scss' || ext === '.sass' || ext === '.less' || ext === '.ts') {
141145
type = ext.replace('.', '');
142146

143147
} else if (ext === '.styl') {

‎package-lock.json

+103-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"detective-cjs": "^2.0.0",
4040
"detective-es6": "^1.2.0",
4141
"detective-less": "^1.0.1",
42+
"detective-postcss": "^2.0.0",
4243
"detective-sass": "^2.0.0",
4344
"detective-scss": "^1.0.0",
4445
"detective-stylus": "^1.0.0",

‎test/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ describe('node-precinct', function() {
7474
assert(cjs.length === 0);
7575
});
7676

77+
it('grabs dependencies of css files', function() {
78+
var css = precinct(read('styles.css'), 'css');
79+
assert.deepEqual(css, ['foo.css', 'baz.css', 'bla.css', 'another.css']);
80+
});
81+
7782
it('grabs dependencies of scss files', function() {
7883
var scss = precinct(read('styles.scss'), 'scss');
7984
assert.deepEqual(scss, ['_foo', 'baz.scss']);
8085
});
8186

82-
it('grabs dependencies of scss files', function() {
87+
it('grabs dependencies of sass files', function() {
8388
var sass = precinct(read('styles.sass'), 'sass');
8489
assert.deepEqual(sass, ['_foo']);
8590
});
@@ -151,6 +156,7 @@ describe('node-precinct', function() {
151156
assert.ok(precinct.paperwork(__dirname + '/es6.js').length);
152157
assert.ok(precinct.paperwork(__dirname + '/styles.scss').length);
153158
assert.ok(precinct.paperwork(__dirname + '/typescript.ts').length);
159+
assert.ok(precinct.paperwork(__dirname + '/styles.css').length);
154160
});
155161

156162
it('throws if the file cannot be found', function() {

‎test/styles.css

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@import "foo.css";
2+
@import url("baz.css");
3+
@value a from 'bla.css';
4+
@value a, b as x from url(another.css);

0 commit comments

Comments
 (0)
Please sign in to comment.