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

postcss-import

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-import - npm Package Compare versions

Comparing version 5.1.1 to 5.2.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 5.2.0 - 2015-04-15
- Added: [glob](https://www.npmjs.com/package/glob) pattern are now supported if `glob` option is set to true ([#34](https://github.com/postcss/postcss-import/pull/34))
- Added: plugin can now be added to PostCSS without calling it as a function ([#27](https://github.com/postcss/postcss-import/pull/27))
# 5.1.1 - 2015-04-10

@@ -2,0 +7,0 @@

49

index.js

@@ -14,2 +14,3 @@ "use strict";

var hash = require("string-hash")
var glob = require("glob")

@@ -28,2 +29,5 @@ /**

module.exports = AtImport
module.exports.postcss = function(styles) {
return module.exports()(styles)
}

@@ -86,3 +90,10 @@ /**

var imports = []
styles.eachAtRule("import", function checkAtRule(atRule) {imports.push(atRule)})
styles.eachAtRule("import", function checkAtRule(atRule) {
if (options.glob && glob.hasMagic(atRule.params)) {
imports = parseGlob(atRule, options, imports)
}
else {
imports.push(atRule)
}
})
imports.forEach(function(atRule) {

@@ -96,2 +107,38 @@ helpers.try(function transformAtImport() {

/**
* parse glob patterns (for relative paths only)
*
* @param {Object} atRule
* @param {Object} options
* @param {Array} imports
*/
function parseGlob(atRule, options, imports) {
var globPattern = atRule.params.replace(/"/g, "")
var files = []
var dir = options.source && options.source.input && options.source.input.file ?
path.dirname(path.resolve(options.root, options.source.input.file)) :
options.root
options.path.forEach(function(p) {
p = path.resolve(dir, p)
var globbed = glob.sync(path.join(p, globPattern))
globbed.forEach(function(file) {
file = path.relative(p, file)
files.push(file)
});
});
files.forEach(function(file) {
var deglobbedAtRule = atRule.clone({
params: "\"" + file + "\""
})
if (deglobbedAtRule.source && deglobbedAtRule.source.input && deglobbedAtRule.source.input.css) {
deglobbedAtRule.source.input.css = atRule.source.input.css.replace(globPattern, file)
}
atRule.parent.insertBefore(atRule, deglobbedAtRule)
imports.push(deglobbedAtRule)
});
atRule.removeSelf()
return imports;
}
/**
* put back at the top ignored url (absolute url)

@@ -98,0 +145,0 @@ *

3

package.json
{
"name": "postcss-import",
"version": "5.1.1",
"version": "5.2.0",
"description": "PostCSS plugin to import CSS files",

@@ -26,2 +26,3 @@ "keywords": [

"clone": "^0.1.17",
"glob": "^5.0.1",
"postcss": "^4.0.2",

@@ -28,0 +29,0 @@ "postcss-message-helpers": "^2.0.0",

@@ -117,2 +117,9 @@ # postcss-import [![Travis Build Status](https://travis-ci.org/postcss/postcss-import.svg)](https://travis-ci.org/postcss/postcss-import) [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/u8l6u3lr6s5u5tpi?svg=true)](https://ci.appveyor.com/project/MoOx/postcss-import)

#### `glob`
Type: `Boolean`
Default: `false`
Set to `true` if you want @import rules to parse glob patterns.
#### Example with some options

@@ -119,0 +126,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