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.0.1 to 5.0.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 5.0.2 - 2015-02-14
- Fixed: indentation and code style are now preserved ([#20](https://github.com/postcss/postcss-import/issues/20))
# 5.0.1 - 2015-02-13

@@ -2,0 +6,0 @@

79

index.js

@@ -80,7 +80,5 @@ "use strict";

function parseStyles(styles, options, cb, importedFiles, ignoredAtRules, media) {
styles.eachAtRule(function checkAtRule(atRule) {
if (atRule.name !== "import") {
return
}
var imports = []
styles.eachAtRule("import", function checkAtRule(atRule) {imports.push(atRule)})
imports.forEach(function(atRule) {
helpers.try(function transformAtImport() {

@@ -106,5 +104,6 @@ readAtImport(atRule, options, cb, importedFiles, ignoredAtRules, media)

ignoredAtRule.params = ignoredAtRules[i][1].fullUri + (ignoredAtRules[i][1].media ? " " + ignoredAtRules[i][1].media : "")
ignoredAtRule.before = "\n"
ignoredAtRule.after = ""
// keep ast ref
ignoredAtRule.parent = styles
// don't use prepend() to avoid weird behavior of normalize()

@@ -114,3 +113,4 @@ styles.nodes.unshift(ignoredAtRule)

if (first && first.before !== undefined) {
// separate remote import a little with others rules if no newlines already
if (first && first.before.indexOf("\n") === -1) {
first.before = "\n\n" + first.before

@@ -132,4 +132,2 @@ }

// adjust media according to current scope

@@ -141,6 +139,9 @@ media = parsedAtImport.media ? (media ? media + " and " : "") + parsedAtImport.media : (media ? media : null)

parsedAtImport.media = media
var atRuleCloned = atRule.clone()
atRuleCloned.parent = atRule.parent.clone()
ignoredAtRules.push([atRuleCloned, parsedAtImport])
atRule.removeSelf()
// save
ignoredAtRules.push([atRule, parsedAtImport])
// detach
detach(atRule)
return

@@ -152,6 +153,9 @@ }

// skip files already imported at the same scope
if (importedFiles[resolvedFilename] && importedFiles[resolvedFilename][media]) {
atRule.removeSelf()
detach(atRule)
return
}
// save imported files to skip them next time
if (!importedFiles[resolvedFilename]) {

@@ -162,2 +166,3 @@ importedFiles[resolvedFilename] = {}

readImportedContent(atRule, parsedAtImport, clone(options), resolvedFilename, cb, importedFiles, ignoredAtRules)

@@ -189,3 +194,3 @@ }

console.log(helpers.message(resolvedFilename + " is empty", atRule.source))
atRule.removeSelf()
detach(atRule)
return

@@ -210,4 +215,12 @@ }

function insertRules(atRule, parsedAtImport, newStyles) {
var newNodes = newStyles.nodes
// wrap rules if the @import have a media query
if (parsedAtImport.media && parsedAtImport.media.length) {
// better output
if (newStyles.nodes && newStyles.nodes.length) {
newStyles.nodes[0].before = newStyles.nodes[0].before || "\n"
// newStyles.nodes[newStyles.nodes.length - 1].after = (newStyles.nodes[newStyles.nodes.length - 1].after || "") + "\n"
}
// wrap new rules with media (media query)

@@ -218,18 +231,22 @@ var wrapper = postcss.atRule({

})
wrapper.append(newStyles)
newStyles = wrapper
// better output
newStyles.before = atRule.before
if (newStyles.nodes && newStyles.nodes.length) {
newStyles.nodes[0].before = newStyles.nodes[0].before || "\n"
}
newStyles.after = atRule.after || "\n"
// keep ast clean
newNodes.forEach(function(node) {node.parent = wrapper})
wrapper.source = atRule.source
// copy code style
wrapper.before = atRule.before
wrapper.after = atRule.after
// move nodes
wrapper.nodes = newNodes
newNodes = [wrapper]
}
else if (newStyles.nodes && newStyles.nodes.length) {
newStyles.nodes[0].before = atRule.before
else if (newNodes && newNodes.length) {
newNodes[0].before = atRule.before
}
atRule.parent.insertBefore(atRule, newStyles)
atRule.removeSelf()
// replace atRule by imported nodes
var nodes = atRule.parent.nodes
nodes.splice.apply(nodes, [nodes.indexOf(atRule), 0].concat(newNodes))
detach(atRule)
}

@@ -330,1 +347,5 @@

}
function detach(node) {
node.parent.nodes.splice(node.parent.nodes.indexOf(node), 1)
}
{
"name": "postcss-import",
"version": "5.0.1",
"version": "5.0.2",
"description": "PostCSS plugin to import CSS files",

@@ -5,0 +5,0 @@ "keywords": [

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