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 3.0.0 to 3.1.0

6

CHANGELOG.md

@@ -0,4 +1,8 @@

# 3.1.0 - 2014-11-24
- Add ability to consume local modules (fix [#12](https://github.com/postcss/postcss-import/issues/12))
# 3.0.0 - 2014-11-21
- Add ability to consume npm packages ([ref](https://github.com/postcss/postcss-import/issues/7)).
- Add ability to consume node modules ([ref](https://github.com/postcss/postcss-import/issues/7)).
This means you don't have to add `node_modules` in the path anymore (or using `@import "../node_modules/..."`).

@@ -5,0 +9,0 @@ Also, `index.css` can be ommited.

61

index.js

@@ -10,5 +10,5 @@ "use strict";

var clone = require("clone")
var findFile = require("find-file")
var resolve = require("resolve")
var postcss = require("postcss")
var helpers = require("postcss-message-helpers")

@@ -48,3 +48,3 @@ /**

parseStyles(styles, options)
parseStyles(styles, options, insertRules)
}

@@ -59,3 +59,3 @@ }

*/
function parseStyles(styles, options, importedFiles, ignoredAtRules, media) {
function parseStyles(styles, options, cb, importedFiles, ignoredAtRules, media) {
var isRoot = ignoredAtRules === undefined

@@ -69,3 +69,5 @@ importedFiles = importedFiles || {}

readAtImport(atRule, options, importedFiles, ignoredAtRules, media)
helpers.try(function transformAtImport() {
readAtImport(atRule, options, cb, importedFiles, ignoredAtRules, media)
}, atRule.source)
})

@@ -109,3 +111,3 @@

*/
function readAtImport(atRule, options, importedFiles, ignoredAtRules, media) {
function readAtImport(atRule, options, cb, importedFiles, ignoredAtRules, media) {
// parse-import module parse entire line

@@ -138,3 +140,3 @@ // @todo extract what can be interesting from this one

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

@@ -149,6 +151,5 @@

* @param {String} resolvedFilename
* @param {Array} importedFiles
* @param {Array} ignoredAtRules
* @param {Function} cb
*/
function insertAtImportContent(atRule, parsedAtImport, options, resolvedFilename, importedFiles, ignoredAtRules) {
function readImportedContent(atRule, parsedAtImport, options, resolvedFilename, cb, importedFiles, ignoredAtRules) {
// add directory containing the @imported file in the paths

@@ -166,3 +167,3 @@ // to allow local import from this file

if (fileContent.trim() === "") {
console.warn(gnuMessage(resolvedFilename + " is empty", atRule.source))
console.warn(helpers.message(resolvedFilename + " is empty", atRule.source))
atRule.removeSelf()

@@ -175,5 +176,5 @@ return

// recursion: import @import from imported file
parseStyles(newStyles, options, importedFiles, ignoredAtRules, parsedAtImport.media)
parseStyles(newStyles, options, cb, importedFiles, ignoredAtRules, parsedAtImport.media)
insertRules(atRule, parsedAtImport, newStyles)
cb(atRule, parsedAtImport, newStyles, resolvedFilename)
}

@@ -221,3 +222,3 @@

if (matches === null) {
throw new Error(gnuMessage("Unable to find uri in '" + str + "'", source))
throw new Error("Unable to find uri in '" + str + "'", source)
}

@@ -238,10 +239,2 @@

function resolveFilename(name, paths, source) {
var file = findFile(name, {path: paths, global: false})
if (file) {
// if (file.length > 1) {
// console.warn(gnuMessage("Warning: multiples files found for `" + name + "`: " + file, source))
// }
return file[0]
}
var root = paths[paths.length - 1]

@@ -251,4 +244,5 @@ var dir = source && source.file ? path.dirname(path.resolve(root, source.file)) : root

try {
file = resolve.sync(name, {
var file = resolve.sync(name, {
basedir: dir,
moduleDirectory: ["node_modules"].concat(paths),
extensions: [".css"],

@@ -265,10 +259,7 @@ packageFilter: function processPackage(pkg) {

throw new Error(
// GNU style message
gnuMessage(
"Failed to find '" + name + "'" +
"\n in [ " +
"\n " + paths.join(",\n ") +
"\n ]",
source
)
"Failed to find '" + name + "'" +
"\n in [ " +
"\n " + paths.join(",\n ") +
"\n ]",
source
)

@@ -300,11 +291,1 @@ }

}
/**
* return GNU style message
*
* @param {String} message
* @param {Object} source
*/
function gnuMessage(message, source) {
return (source ? (source.file ? source.file : "<css input>") + ":" + source.start.line + ":" + source.start.column + " " : "") + message
}
{
"name": "postcss-import",
"version": "3.0.0",
"version": "3.1.0",
"description": "PostCSS plugin to import CSS files",

@@ -26,4 +26,4 @@ "keywords": [

"clone": "^0.1.17",
"find-file": "^0.1.4",
"postcss": "^3.0.0",
"postcss-message-helpers": "^1.1.0",
"resolve": "^1.0.0"

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