Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-mixins

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-mixins - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.editorconfig

4

CHANGELOG.md

@@ -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 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc