diff --git a/index.js b/index.js index e56631cc..6d2d4db7 100755 --- a/index.js +++ b/index.js @@ -5,6 +5,7 @@ var joinMedia = require("./lib/join-media") var resolveId = require("./lib/resolve-id") var loadContent = require("./lib/load-content") var parseStatements = require("./lib/parse-statements") +var promiseEach = require("promise-each") function AtImport(options) { options = assign({ @@ -163,7 +164,7 @@ function parseStyles( ) { var statements = parseStatements(result, styles) - return Promise.all(statements.map(function(stmt) { + return Promise.resolve(statements).then(promiseEach(function(stmt) { stmt.media = joinMedia(media, stmt.media || []) // skip protocol base uri (protocol://url) or protocol-relative diff --git a/package.json b/package.json index 6dc62023..97f13d7b 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "pkg-resolve": "^0.1.7", "postcss": "^5.0.14", "postcss-value-parser": "^3.2.3", + "promise-each": "^2.2.0", "read-cache": "^1.0.0", "resolve": "^1.1.7" }, diff --git a/test/order.js b/test/order.js index 40bbe08f..cf1ef1a2 100644 --- a/test/order.js +++ b/test/order.js @@ -3,27 +3,13 @@ import compareFixtures from "./helpers/compare-fixtures" test(`should order nested imports correctly`, t => { var first = true - var resolve = require("resolve") + var path = require("path") return compareFixtures(t, "order", { path: "fixtures/imports", - resolve: (id, base, opts) => { - var resolveOpts = { - basedir: base, - moduleDirectory: [], - paths: opts.path, - extensions: [ ".css" ], - } - - return new Promise(function(res, rej) { - var doResolve = () => { - resolve(id, resolveOpts, function(err, path) { - if (err) { - return rej(err) - } - res(path) - }) - } + resolve: (id) => { + return new Promise(function(res) { + var doResolve = () => res(path.resolve("fixtures/imports", id)) if (first) { // Delay the first import so the second gets loaded first diff --git a/test/plugins.js b/test/plugins.js index d5402b77..040bdc69 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -29,7 +29,7 @@ test("should apply plugins to root", t => { }) .then(() => { t.deepEqual(atRules, [ "import" ]) - t.deepEqual(rules, [ "bar", "foo" ]) + t.deepEqual(rules, [ "foo", "bar" ]) }) })