From 1fbeca62a6fc84e39e0fcd53cd3baaf95b94a3a2 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sat, 9 Jan 2016 22:01:48 +0300 Subject: [PATCH 1/2] Remove glob support --- lib/resolve-id.js | 8 ----- package.json | 1 - test/fixtures/glob-base.css | 1 - test/fixtures/glob-base.expected.css | 1 - test/fixtures/glob-missing.css | 2 -- test/fixtures/glob-missing.expected.css | 1 - test/fixtures/glob-resolve.css | 5 --- test/fixtures/glob-resolve.expected.css | 10 ------ test/fixtures/glob.css | 2 -- test/fixtures/glob.expected.css | 3 -- test/glob.js | 41 ------------------------- 11 files changed, 75 deletions(-) delete mode 100644 test/fixtures/glob-base.css delete mode 100644 test/fixtures/glob-base.expected.css delete mode 100644 test/fixtures/glob-missing.css delete mode 100644 test/fixtures/glob-missing.expected.css delete mode 100644 test/fixtures/glob-resolve.css delete mode 100644 test/fixtures/glob-resolve.expected.css delete mode 100644 test/fixtures/glob.css delete mode 100644 test/fixtures/glob.expected.css delete mode 100644 test/glob.js diff --git a/lib/resolve-id.js b/lib/resolve-id.js index ec470e77..0dc4cc75 100644 --- a/lib/resolve-id.js +++ b/lib/resolve-id.js @@ -1,6 +1,5 @@ var fs = require("fs") var path = require("path") -var globby = require("globby") var resolve = require("resolve") var moduleDirectories = [ @@ -36,13 +35,6 @@ function resolveModule(id, opts) { module.exports = function(id, base, options) { var paths = options.path - if (options.glob) { - paths = [ base ].concat(paths) - return globby(paths.map(function(p) { - return path.resolve(p, id) - })) - } - var resolveOpts = { basedir: base, moduleDirectory: moduleDirectories, diff --git a/package.json b/package.json index 7923d47d..4ae27683 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "index.js" ], "dependencies": { - "globby": "^4.0.0", "object-assign": "^4.0.1", "postcss": "^5.0.2", "postcss-value-parser": "^3.2.3", diff --git a/test/fixtures/glob-base.css b/test/fixtures/glob-base.css deleted file mode 100644 index d26c555a..00000000 --- a/test/fixtures/glob-base.css +++ /dev/null @@ -1 +0,0 @@ -@import "imports*/bar.css"; diff --git a/test/fixtures/glob-base.expected.css b/test/fixtures/glob-base.expected.css deleted file mode 100644 index f3bf37e4..00000000 --- a/test/fixtures/glob-base.expected.css +++ /dev/null @@ -1 +0,0 @@ -bar{} diff --git a/test/fixtures/glob-missing.css b/test/fixtures/glob-missing.css deleted file mode 100644 index a9a40a79..00000000 --- a/test/fixtures/glob-missing.css +++ /dev/null @@ -1,2 +0,0 @@ -@import "./missing*.css"; -@import "foobar.css"; diff --git a/test/fixtures/glob-missing.expected.css b/test/fixtures/glob-missing.expected.css deleted file mode 100644 index a1fb7e19..00000000 --- a/test/fixtures/glob-missing.expected.css +++ /dev/null @@ -1 +0,0 @@ -foobar{} diff --git a/test/fixtures/glob-resolve.css b/test/fixtures/glob-resolve.css deleted file mode 100644 index 8bfcb592..00000000 --- a/test/fixtures/glob-resolve.css +++ /dev/null @@ -1,5 +0,0 @@ -@import "imports/missing-glob.css"; - -@import "imports/bar.css"; - -@import "imports/foo-*"; diff --git a/test/fixtures/glob-resolve.expected.css b/test/fixtures/glob-resolve.expected.css deleted file mode 100644 index 07e51126..00000000 --- a/test/fixtures/glob-resolve.expected.css +++ /dev/null @@ -1,10 +0,0 @@ -bar{} - -body { - foo: foo; - baz: baz; -} - -foo{} - -foo.recursive{} diff --git a/test/fixtures/glob.css b/test/fixtures/glob.css deleted file mode 100644 index b8047be0..00000000 --- a/test/fixtures/glob.css +++ /dev/null @@ -1,2 +0,0 @@ -@import "./foobar*.css"; -@import "by-hand/*.css"; diff --git a/test/fixtures/glob.expected.css b/test/fixtures/glob.expected.css deleted file mode 100644 index f7815894..00000000 --- a/test/fixtures/glob.expected.css +++ /dev/null @@ -1,3 +0,0 @@ -foobar{} -foobarbaz{} -.byHand{} diff --git a/test/glob.js b/test/glob.js deleted file mode 100644 index e0d7c8d7..00000000 --- a/test/glob.js +++ /dev/null @@ -1,41 +0,0 @@ -import test from "ava" -import compareFixtures from "./lib/compare-fixtures" -import path from "path" -import globby from "globby" - -test("should handle a glob pattern", t => { - return compareFixtures(t, "glob", { - path: [ - "fixtures/imports", - "node_modules", - "web_modules", - ], - glob: true, - }) -}) - -test("should handle glob in base dir", t => { - return compareFixtures(t, "glob-base", { - path: [], - glob: true, - }, { - from: "fixtures/glob-base.css", - }) -}) - -test("should fail silently, skipping the globbed import," + - " if no files found", t => { - return compareFixtures(t, "glob-missing", { - glob: true, - }) -}) - -test("should handle a glob by custom resolver", t => { - return compareFixtures(t, "glob-resolve", { - resolve: (id, base) => { - return globby.sync(path.resolve(base, id)) - }, - }, { - from: "fixtures/glob-resolve.css", - }) -}) From b6ae4249102662ebe05cc34106853887fd9a30b0 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sat, 9 Jan 2016 22:05:19 +0300 Subject: [PATCH 2/2] Add documentation and changelog --- CHANGELOG.md | 13 +++++++++++++ README.md | 8 -------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab09961e..e4bb5623 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,19 @@ postcssImport({ }) ``` +- Removed: glob support +([#146](https://github.com/postcss/postcss-import/pull/146)) + +Globs can be implemented with custom `resolve` option + +```js +postcssImport({ + resolve: function(id, base) { + return glob.sync(path.join(base, id)) + } +}) +``` + # 7.1.3 - 2015-11-05 - Fixed: ensure node 0.12 compatibility, round 2 diff --git a/README.md b/README.md index 364ac314..4063eca2 100755 --- a/README.md +++ b/README.md @@ -125,14 +125,6 @@ Default: `null` Function called after the import process. Take one argument (array of imported files). -#### `glob` - -Type: `Boolean` -Default: `false` - -Set to `true` if you want @import rules to parse glob patterns. -Files will be searched in base directory and paths specified in `path` option. - #### `resolve` Type: `Function`