Skip to content

Commit

Permalink
Upgrade to PostCSS v5
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Aug 24, 2015
1 parent 5db759d commit 0626939
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
language: node_js
node_js:
- '0.12'
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

environment:
matrix:
- nodejs_version: 0.10
- nodejs_version: 0.12

version: "{build}"
build: off
Expand Down
21 changes: 10 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ var postcss = require("postcss")
var helpers = require("postcss-message-helpers")
var glob = require("glob")

var Promize = global.Promise || require("es6-promise").Promise
var resolvedPromise = new Promize(function(resolvePromise) {
var resolvedPromise = new Promise(function(resolvePromise) {
resolvePromise()
})

Expand Down Expand Up @@ -131,7 +130,7 @@ function parseStyles(
processor
) {
var imports = []
styles.eachAtRule("import", function checkAtRule(atRule) {
styles.walkAtRules("import", function checkAtRule(atRule) {
if (atRule.nodes) {
result.warn(warnNodesMessage, {node: atRule})
}
Expand All @@ -157,7 +156,7 @@ function parseStyles(
})

if (options.async) {
return Promize.all(importResults)
return Promise.all(importResults)
}
// else (!options.async)
// nothing
Expand Down Expand Up @@ -204,7 +203,7 @@ function parseGlob(atRule, options, imports) {
atRule.parent.insertBefore(atRule, deglobbedAtRule)
imports.push(deglobbedAtRule)
})
atRule.removeSelf()
atRule.remove()

return imports
}
Expand Down Expand Up @@ -234,8 +233,8 @@ function addIgnoredAtRulesOnTop(styles, ignoredAtRules) {

// 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
first.raws.before.indexOf("\n") === -1) {
first.raws.before = "\n\n" + first.raws.before
}
}
}
Expand Down Expand Up @@ -420,7 +419,7 @@ function insertRules(atRule, parsedAtImport, newStyles) {
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[0].raws.before = newStyles.nodes[0].raws.before || "\n"
}

// wrap new rules with media (media query)
Expand All @@ -436,15 +435,15 @@ function insertRules(atRule, parsedAtImport, newStyles) {
wrapper.source = atRule.source

// copy code style
wrapper.before = atRule.before
wrapper.after = atRule.after
wrapper.raws.before = atRule.raws.before
wrapper.raws.after = atRule.raws.after

// move nodes
wrapper.nodes = newNodes
newNodes = [wrapper]
}
else if (newNodes && newNodes.length) {
newNodes[0].before = atRule.before
newNodes[0].raws.before = atRule.raws.before
}

// keep AST clean
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
],
"dependencies": {
"clone": "^1.0.2",
"es6-promise": "^3.0.2",
"glob": "^5.0.14",
"object-assign": "^3.0.0",
"postcss": "^4.1.16",
"object-assign": "^4.0.1",
"postcss": "^5.0.2",
"postcss-message-helpers": "^2.0.0",
"resolve": "^1.1.6"
},
Expand Down
8 changes: 4 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ test("@import", function(t) {
plugins: [
postcss.plugin("postcss-no-foo", function() {
return function(css) {
css.eachDecl("foo", function(decl) {
decl.removeSelf()
css.walkDecls("foo", function(decl) {
decl.remove()
})
}
}),
postcss.plugin("postcss-no-bar", function() {
return function(css) {
css.eachDecl("bar", function(decl) {
decl.removeSelf()
css.walkDecls("bar", function(decl) {
decl.remove()
})
}
}),
Expand Down

0 comments on commit 0626939

Please sign in to comment.