From 03dca8bdc5c06dfbe0d9a33aa26850fed62c2bec Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Tue, 15 Dec 2015 14:20:58 +0300 Subject: [PATCH 1/3] Use async mode only --- index.js | 37 +++++++++++-------------------------- test/index.js | 15 --------------- 2 files changed, 11 insertions(+), 41 deletions(-) diff --git a/index.js b/index.js index aae9d248..6ce7605c 100755 --- a/index.js +++ b/index.js @@ -31,7 +31,6 @@ var warnNodesMessage = function AtImport(options) { options = assign({ root: process.cwd(), - async: false, path: [], skipDuplicates: true, }, options || {}) @@ -98,11 +97,7 @@ function AtImport(options) { } } - if (options.async) { - return parsedStylesResult.then(onParseEnd) - } - // else (!options.async) - onParseEnd() + return parsedStylesResult.then(onParseEnd) } } @@ -156,11 +151,7 @@ function parseStyles( }, atRule.source) }) - if (options.async) { - return Promise.all(importResults) - } - // else (!options.async) - // nothing + return Promise.all(importResults) } /** @@ -377,21 +368,15 @@ function readImportedContent( processor ) - if (options.async) { - return parsedResult.then(function() { - return processor.process(newStyles) - }) - .then(function(newResult) { - result.messages = result.messages.concat(newResult.messages) - }) - .then(function() { - insertRules(atRule, parsedAtImport, newStyles) - }) - } - // else (!options.async) - var newResult = processor.process(newStyles) - result.messages = result.messages.concat(newResult.messages) - insertRules(atRule, parsedAtImport, newStyles) + return parsedResult.then(function() { + return processor.process(newStyles) + }) + .then(function(newResult) { + result.messages = result.messages.concat(newResult.messages) + }) + .then(function() { + insertRules(atRule, parsedAtImport, newStyles) + }) } /** diff --git a/test/index.js b/test/index.js index 5f2022b5..e01882d6 100755 --- a/test/index.js +++ b/test/index.js @@ -362,18 +362,3 @@ test("plugins option", function(t) { t.pass("should remain silent when value is an empty array") }) }) - -test("sync", function(t) { - var css = "body{}" - t.equal( - postcss() - .use(atImport()) - .process(css) - .css - , - css, - "should still work sync" - ) - - t.end() -}) From c9ebdfa097b868ffd2e30e4a1567ae788b86d5b8 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Tue, 15 Dec 2015 17:25:05 +0300 Subject: [PATCH 2/3] Update readme and changelog --- CHANGELOG.md | 4 ++++ README.md | 23 +++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa81c390..7e4e1841 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 8.0.0 + +- Changed: used only async mode + # 7.1.3 - 2015-11-05 - Fixed: ensure node 0.12 compatibility, round 2 diff --git a/README.md b/README.md index 33c6ac59..80078979 100755 --- a/README.md +++ b/README.md @@ -39,15 +39,17 @@ var atImport = require("postcss-import") var css = fs.readFileSync("css/input.css", "utf8") // process css -var output = postcss() +postcss() .use(atImport()) .process(css, { // `from` option is required so relative import can work from input dirname from: "css/input.css" }) - .css + .then(function (result) { + var output = result.css -console.log(output) + console.log(output) + }) ``` Using this `input.css`: @@ -102,15 +104,6 @@ Default: `process.cwd()` or _dirname of [the postcss `from`](https://github.com/ A string or an array of paths in where to look for files. _Note: nested `@import` will additionally benefit of the relative dirname of imported files._ -#### `async` - -Type: `Boolean` -Default: `false` - -Allow to enable PostCSS async API usage. Before enabling this, check that your -runner allow async usage. -_Note: this is not enabling async fs read yet._ - #### `transform` Type: `Function` @@ -187,13 +180,15 @@ It's equivalent to `onImport` with the following code: var postcss = require("postcss") var atImport = require("postcss-import") -var css = postcss() +postcss() .use(atImport({ path: ["src/css"] transform: require("css-whitespace") })) .process(cssString) - .css + .then(function (result) { + var css = result.css + }) ``` --- From a61081b30341af971dff57c0d0aed690e5f9bbcf Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Tue, 15 Dec 2015 17:39:01 +0300 Subject: [PATCH 3/3] Fix changelog --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e4e1841..86ace66d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ -# 8.0.0 - -- Changed: used only async mode +- Removed: async mode/option +([#107](https://github.com/postcss/postcss-import/pull/107)) # 7.1.3 - 2015-11-05