postcss-mixins
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -0,1 +1,5 @@ | ||
## 1.0.2 | ||
* Do not throw error on missed mixin dir (by Bogdan Chadkin). | ||
* Use async plugin API (by Bogdan Chadkin). | ||
## 1.0.1 | ||
@@ -2,0 +6,0 @@ * Fix using relative URL in `mixinsDir` (by Bogdan Chadkin). |
57
index.js
var postcss = require('postcss'); | ||
var vars = require('postcss-simple-vars'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var glob = require('glob'); | ||
var globby = require('globby'); | ||
@@ -141,28 +140,20 @@ var stringToAtRule = function (str, obj) { | ||
var i; | ||
var cwd = process.cwd(); | ||
var globs = []; | ||
var mixins = { }; | ||
var cwd = process.cwd(); | ||
if ( opts.mixinsDir ) { | ||
var dirs = opts.mixinsDir; | ||
if ( !(dirs instanceof Array) ) dirs = [dirs]; | ||
dirs.forEach(function (dir) { | ||
var files = fs.readdirSync(dir); | ||
for ( var j = 0; j < files.length; j++ ) { | ||
var file = path.join(dir, files[j]); | ||
if ( path.extname(file) === '.js' ) { | ||
var name = path.basename(file, '.js'); | ||
file = path.join(cwd, path.relative(cwd, file)); | ||
mixins[name] = { mixin: require(file) }; | ||
} | ||
} | ||
if ( !Array.isArray(opts.mixinsDir) ) { | ||
opts.mixinsDir = [opts.mixinsDir]; | ||
} | ||
globs = opts.mixinsDir.map(function (dir) { | ||
return path.join(dir, '*.js'); | ||
}); | ||
} | ||
if ( opts.mixinsFiles ) { | ||
var globs = opts.mixinsFiles; | ||
if ( !(globs instanceof Array) ) globs = [globs]; | ||
if ( opts.mixinsFiles ) globs = globs.concat(opts.mixinsFiles); | ||
globs.forEach(function (pattern) { | ||
glob.sync(pattern).forEach(function (file) { | ||
return function (css, result) { | ||
return globby(globs).then(function (files) { | ||
files.forEach(function (file) { | ||
var name = path.basename(file, path.extname(file)); | ||
@@ -172,20 +163,18 @@ file = path.join(cwd, path.relative(cwd, file)); | ||
}); | ||
}); | ||
} | ||
if ( typeof opts.mixins === 'object' ) { | ||
for ( i in opts.mixins ) mixins[i] = { mixin: opts.mixins[i] }; | ||
} | ||
return function (css, result) { | ||
css.walkAtRules(function (rule) { | ||
if ( rule.name === 'mixin' ) { | ||
insertMixin(result, mixins, rule, opts); | ||
} else if ( rule.name === 'define-mixin' ) { | ||
defineMixin(result, mixins, rule); | ||
if ( typeof opts.mixins === 'object' ) { | ||
for ( i in opts.mixins ) { | ||
mixins[i] = { mixin: opts.mixins[i] }; | ||
} | ||
} | ||
css.walkAtRules(function (rule) { | ||
if ( rule.name === 'mixin' ) { | ||
insertMixin(result, mixins, rule, opts); | ||
} else if ( rule.name === 'define-mixin' ) { | ||
defineMixin(result, mixins, rule); | ||
} | ||
}); | ||
}); | ||
}; | ||
}); |
{ | ||
"name": "postcss-mixins", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "PostCSS plugin for mixins", | ||
@@ -19,5 +19,5 @@ "keywords": [ | ||
"dependencies": { | ||
"postcss-simple-vars": "^1.0.0", | ||
"postcss": "^5.0.2", | ||
"glob": "^5.0.14" | ||
"postcss-simple-vars": "^1.0.1", | ||
"postcss": "^5.0.9", | ||
"globby": "^3.0.1" | ||
}, | ||
@@ -27,4 +27,4 @@ "devDependencies": { | ||
"gulp-mocha": "2.1.3", | ||
"mocha": "2.2.5", | ||
"chai": "3.2.0", | ||
"mocha": "2.3.3", | ||
"chai": "3.3.0", | ||
"gulp": "3.9.0" | ||
@@ -31,0 +31,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
8
1
18329
153
+ Addedglobby@^3.0.1
+ Addedarray-union@1.0.2(transitive)
+ Addedarray-uniq@1.0.3(transitive)
+ Addedarrify@1.0.1(transitive)
+ Addedglobby@3.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedpify@2.3.0(transitive)
+ Addedpinkie@1.0.0(transitive)
+ Addedpinkie-promise@1.0.0(transitive)
- Removedglob@^5.0.14
Updatedpostcss@^5.0.9
Updatedpostcss-simple-vars@^1.0.1