From c9c0346c1cbded337c9eaf8e19e373b8aaf3e829 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Thu, 22 Dec 2016 18:21:07 +0100 Subject: [PATCH 01/23] Add .gitattributes file and add a setting to treat files in the dist directory as binary files. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..624dc5a --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +dist/* binary From 9d6c099425c7a3f78548c9314f9d96fdbcfe7ffb Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Thu, 5 Jan 2017 10:52:37 +0100 Subject: [PATCH 02/23] Integrate the node-sass-filter-importer according to #80 --- dist/MagicImporter.js | 54 ++++++++++++++++------- dist/cli.js | 52 +++++++++++++++------- dist/index.js | 52 +++++++++++++++------- js/lib/MagicImporter.js | 46 ++++++++++++++----- package.json | 3 ++ test/files/combined-reference.css | 12 +++++ test/files/filter-reference.css | 8 ++++ test/files/filter.scss | 10 +++++ test/files/test-imports/test-import3.scss | 17 +++++++ test/files/test-imports/test-import4.scss | 17 +++++++ test/test.js | 11 +++++ yarn.lock | 25 +++++++++-- 12 files changed, 248 insertions(+), 59 deletions(-) create mode 100644 test/files/filter-reference.css create mode 100644 test/files/filter.scss create mode 100644 test/files/test-imports/test-import3.scss create mode 100644 test/files/test-imports/test-import4.scss diff --git a/dist/MagicImporter.js b/dist/MagicImporter.js index ff11461..799cfcb 100644 --- a/dist/MagicImporter.js +++ b/dist/MagicImporter.js @@ -2,12 +2,15 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } -var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter.js')); -var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); -var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var path = _interopDefault(require('path')); +var postcssSyntax = _interopDefault(require('postcss-scss')); var uniqueConcat = _interopDefault(require('unique-concat')); +var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/FilterImporter.js')); +var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter.js')); +var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); +var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); /** * Selector specific imports, module importing, @@ -74,19 +77,19 @@ MagicImporter.prototype.store = function store (url, selectorFilters) { var absoluteUrl = this.getAbsoluteUrl(url); // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { + if (this.onceStore[absoluteUrl] === undefined) { this.onceStore[absoluteUrl] = selectorFilters; return { url: absoluteUrl, selectorFilters: selectorFilters }; } - // URL is in store without filters, filters given: load the URL. + // URL is in store without filters, filters given: load the URL. if (this.onceStore[absoluteUrl] === null && selectorFilters) { // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); + console.warn(("Warning: double import of file \"" + url + "\"")); return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } - // URL and filters in store, URL without filters given: + // URL and filters in store, URL without filters given: // load and remove filters from store. if (this.onceStore[absoluteUrl] && !selectorFilters) { // eslint-disable-next-line no-console @@ -122,13 +125,17 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { var this$1 = this; var data = null; - var resolvedUrl = url; + // @TODO: Ugly. + var resolvedUrl = url.split("from")[1] || url; + resolvedUrl = resolvedUrl.trim(); + + // Parse url and eventually extract filters. + var filterImporter = new FilterImporter(this.options); + var filterNames = filterImporter.parseUrl(url).filterNames; - // Parse url to eventually extract selector filters. + // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); - var urlData = selectorImporter.parseUrl(resolvedUrl); - resolvedUrl = urlData.url; - var selectorFilters = urlData.selectorFilters; + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; // Try to resolve glob pattern url. var globImporter = new GlobImporter(this.options); @@ -162,8 +169,23 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { resolvedUrl = storedData.url; selectorFilters = storedData.selectorFilters; - // Filter selectors. - var filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + // Filter. + var filteredContents; + // @TODO: This is ugly, maybe refactor. + if (selectorFilters) { + filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + } + if (filterNames) { + if (filteredContents) { + filteredContents = CssNodeExtract.processSync({ + css: filteredContents, + filterNames: filterNames, + postcssSyntax: postcssSyntax + }); + } else { + filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + } + } if (filteredContents) { data = { file: resolvedUrl, @@ -183,7 +205,7 @@ MagicImporter.prototype.resolve = function resolve (url) { var this$1 = this; return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); + promiseResolve(this$1.resolveSync(url)); }); }; diff --git a/dist/cli.js b/dist/cli.js index 834fc15..1a0345d 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -3,11 +3,14 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var path = _interopDefault(require('path')); +var CssNodeExtract = _interopDefault(require('css-node-extract')); +var fs = _interopDefault(require('fs')); +var postcssSyntax = _interopDefault(require('postcss-scss')); +var uniqueConcat = _interopDefault(require('unique-concat')); +var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/FilterImporter.js')); var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter.js')); var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); -var fs = _interopDefault(require('fs')); -var uniqueConcat = _interopDefault(require('unique-concat')); /** * Selector specific imports, module importing, @@ -74,19 +77,19 @@ MagicImporter.prototype.store = function store (url, selectorFilters) { var absoluteUrl = this.getAbsoluteUrl(url); // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { + if (this.onceStore[absoluteUrl] === undefined) { this.onceStore[absoluteUrl] = selectorFilters; return { url: absoluteUrl, selectorFilters: selectorFilters }; } - // URL is in store without filters, filters given: load the URL. + // URL is in store without filters, filters given: load the URL. if (this.onceStore[absoluteUrl] === null && selectorFilters) { // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); + console.warn(("Warning: double import of file \"" + url + "\"")); return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } - // URL and filters in store, URL without filters given: + // URL and filters in store, URL without filters given: // load and remove filters from store. if (this.onceStore[absoluteUrl] && !selectorFilters) { // eslint-disable-next-line no-console @@ -122,13 +125,17 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { var this$1 = this; var data = null; - var resolvedUrl = url; + // @TODO: Ugly. + var resolvedUrl = url.split("from")[1] || url; + resolvedUrl = resolvedUrl.trim(); + + // Parse url and eventually extract filters. + var filterImporter = new FilterImporter(this.options); + var filterNames = filterImporter.parseUrl(url).filterNames; - // Parse url to eventually extract selector filters. + // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); - var urlData = selectorImporter.parseUrl(resolvedUrl); - resolvedUrl = urlData.url; - var selectorFilters = urlData.selectorFilters; + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; // Try to resolve glob pattern url. var globImporter = new GlobImporter(this.options); @@ -162,8 +169,23 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { resolvedUrl = storedData.url; selectorFilters = storedData.selectorFilters; - // Filter selectors. - var filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + // Filter. + var filteredContents; + // @TODO: This is ugly, maybe refactor. + if (selectorFilters) { + filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + } + if (filterNames) { + if (filteredContents) { + filteredContents = CssNodeExtract.processSync({ + css: filteredContents, + filterNames: filterNames, + postcssSyntax: postcssSyntax + }); + } else { + filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + } + } if (filteredContents) { data = { file: resolvedUrl, @@ -183,7 +205,7 @@ MagicImporter.prototype.resolve = function resolve (url) { var this$1 = this; return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); + promiseResolve(this$1.resolveSync(url)); }); }; diff --git a/dist/index.js b/dist/index.js index 5403c97..bda5941 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3,11 +3,14 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var path = _interopDefault(require('path')); +var CssNodeExtract = _interopDefault(require('css-node-extract')); +var fs = _interopDefault(require('fs')); +var postcssSyntax = _interopDefault(require('postcss-scss')); +var uniqueConcat = _interopDefault(require('unique-concat')); +var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/FilterImporter.js')); var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter.js')); var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); -var fs = _interopDefault(require('fs')); -var uniqueConcat = _interopDefault(require('unique-concat')); /** * Selector specific imports, module importing, @@ -74,19 +77,19 @@ MagicImporter.prototype.store = function store (url, selectorFilters) { var absoluteUrl = this.getAbsoluteUrl(url); // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { + if (this.onceStore[absoluteUrl] === undefined) { this.onceStore[absoluteUrl] = selectorFilters; return { url: absoluteUrl, selectorFilters: selectorFilters }; } - // URL is in store without filters, filters given: load the URL. + // URL is in store without filters, filters given: load the URL. if (this.onceStore[absoluteUrl] === null && selectorFilters) { // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); + console.warn(("Warning: double import of file \"" + url + "\"")); return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } - // URL and filters in store, URL without filters given: + // URL and filters in store, URL without filters given: // load and remove filters from store. if (this.onceStore[absoluteUrl] && !selectorFilters) { // eslint-disable-next-line no-console @@ -122,13 +125,17 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { var this$1 = this; var data = null; - var resolvedUrl = url; + // @TODO: Ugly. + var resolvedUrl = url.split("from")[1] || url; + resolvedUrl = resolvedUrl.trim(); + + // Parse url and eventually extract filters. + var filterImporter = new FilterImporter(this.options); + var filterNames = filterImporter.parseUrl(url).filterNames; - // Parse url to eventually extract selector filters. + // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); - var urlData = selectorImporter.parseUrl(resolvedUrl); - resolvedUrl = urlData.url; - var selectorFilters = urlData.selectorFilters; + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; // Try to resolve glob pattern url. var globImporter = new GlobImporter(this.options); @@ -162,8 +169,23 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { resolvedUrl = storedData.url; selectorFilters = storedData.selectorFilters; - // Filter selectors. - var filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + // Filter. + var filteredContents; + // @TODO: This is ugly, maybe refactor. + if (selectorFilters) { + filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + } + if (filterNames) { + if (filteredContents) { + filteredContents = CssNodeExtract.processSync({ + css: filteredContents, + filterNames: filterNames, + postcssSyntax: postcssSyntax + }); + } else { + filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + } + } if (filteredContents) { data = { file: resolvedUrl, @@ -183,7 +205,7 @@ MagicImporter.prototype.resolve = function resolve (url) { var this$1 = this; return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); + promiseResolve(this$1.resolveSync(url)); }); }; diff --git a/js/lib/MagicImporter.js b/js/lib/MagicImporter.js index 05ea9f0..a11723e 100644 --- a/js/lib/MagicImporter.js +++ b/js/lib/MagicImporter.js @@ -1,10 +1,16 @@ -import GlobImporter from 'node-sass-glob-importer/dist/GlobImporter.js'; -import PackageImporter from 'node-sass-package-importer/dist/PackageImporter.js'; -import SelectorImporter from 'node-sass-selector-importer/dist/SelectorImporter.js'; +// @TODO: Add README info about filter importing. + +import CssNodeExtract from 'css-node-extract'; import fs from 'fs'; import path from 'path'; +import postcssSyntax from 'postcss-scss'; import uniqueConcat from 'unique-concat'; +import FilterImporter from 'node-sass-filter-importer/dist/lib/FilterImporter.js'; +import GlobImporter from 'node-sass-glob-importer/dist/GlobImporter.js'; +import PackageImporter from 'node-sass-package-importer/dist/PackageImporter.js'; +import SelectorImporter from 'node-sass-selector-importer/dist/SelectorImporter.js'; + /** * Selector specific imports, module importing, * globbing support, import files only once. @@ -66,6 +72,7 @@ export default class MagicImporter { * @return {boolean|Object} - Absolute URL and selector filters or false. */ store(url, selectorFilters = null) { + // @TODO: Add filter logic. const absoluteUrl = this.getAbsoluteUrl(url); // URL is not in store: store and load the URL. @@ -116,13 +123,17 @@ export default class MagicImporter { */ resolveSync(url) { let data = null; - let resolvedUrl = url; + // @TODO: Ugly. + let resolvedUrl = url.split(`from`)[1] || url; + resolvedUrl = resolvedUrl.trim(); + + // Parse url and eventually extract filters. + const filterImporter = new FilterImporter(this.options); + const filterNames = filterImporter.parseUrl(url).filterNames; - // Parse url to eventually extract selector filters. + // Parse url and eventually extract selector filters. const selectorImporter = new SelectorImporter(this.options); - const urlData = selectorImporter.parseUrl(resolvedUrl); - resolvedUrl = urlData.url; - let selectorFilters = urlData.selectorFilters; + let selectorFilters = selectorImporter.parseUrl(url).selectorFilters; // Try to resolve glob pattern url. const globImporter = new GlobImporter(this.options); @@ -156,8 +167,23 @@ export default class MagicImporter { resolvedUrl = storedData.url; selectorFilters = storedData.selectorFilters; - // Filter selectors. - const filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + // Filter. + let filteredContents; + // @TODO: This is ugly, maybe refactor. + if (selectorFilters) { + filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + } + if (filterNames) { + if (filteredContents) { + filteredContents = CssNodeExtract.processSync({ + css: filteredContents, + filterNames, + postcssSyntax + }); + } else { + filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + } + } if (filteredContents) { data = { file: resolvedUrl, diff --git a/package.json b/package.json index 05e243c..b8e7465 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,12 @@ "url": "https://github.com/maoberlehner/node-sass-magic-importer/issues" }, "dependencies": { + "css-node-extract": "^0.1.0", + "node-sass-filter-importer": "^0.1.0", "node-sass-glob-importer": "^3.0.0", "node-sass-package-importer": "^3.0.1", "node-sass-selector-importer": "^4.0.0", + "postcss-scss": "^0.4.0", "unique-concat": "^0.2.2" }, "devDependencies": { diff --git a/test/files/combined-reference.css b/test/files/combined-reference.css index 66cc70b..76dfecd 100644 --- a/test/files/combined-reference.css +++ b/test/files/combined-reference.css @@ -16,6 +16,18 @@ .test-import2-3 { content: 'Test import 2-3'; } +.test-import3-1 { + content: 'Test import 3-1'; } + +.test-import3-2 { + content: 'Test import 3-2'; } + +.test-import4-1 { + content: 'Test import 4-1'; } + +.test-import4-2 { + content: 'Test import 4-2'; } + .test-sub-import1 { content: 'Test sub import 1'; } diff --git a/test/files/filter-reference.css b/test/files/filter-reference.css new file mode 100644 index 0000000..5a7272c --- /dev/null +++ b/test/files/filter-reference.css @@ -0,0 +1,8 @@ +.test-import4-1 { + content: 'Test import 4-1'; } + +.variable-test { + content: 3; } + +.mixin-test .selector-inside-mixin-at-rule { + content: 'Selector inside mixin at rule'; } diff --git a/test/files/filter.scss b/test/files/filter.scss new file mode 100644 index 0000000..845ff70 --- /dev/null +++ b/test/files/filter.scss @@ -0,0 +1,10 @@ +@import '[variables, mixins] from test-imports/test-import3.scss'; +@import '[rules] { .test-import4-1 } from test-imports/test-import4.scss'; + +.variable-test { + content: $variable1; +} + +.mixin-test { + @include mixin-at-rule(); +} diff --git a/test/files/test-imports/test-import3.scss b/test/files/test-imports/test-import3.scss new file mode 100644 index 0000000..7baba82 --- /dev/null +++ b/test/files/test-imports/test-import3.scss @@ -0,0 +1,17 @@ +$variable1: 3; +$variable2: 3; +$variable3: 3; + +.test-import3-1 { + content: 'Test import 3-1'; +} + +.test-import3-2 { + content: 'Test import 3-2'; +} + +@mixin mixin-at-rule { + .selector-inside-mixin-at-rule { + content: 'Selector inside mixin at rule'; + } +} diff --git a/test/files/test-imports/test-import4.scss b/test/files/test-imports/test-import4.scss new file mode 100644 index 0000000..0051f22 --- /dev/null +++ b/test/files/test-imports/test-import4.scss @@ -0,0 +1,17 @@ +$variable1: 4; +$variable2: 4; +$variable3: 4; + +.test-import4-1 { + content: 'Test import 4-1'; +} + +.test-import4-2 { + content: 'Test import 4-2'; +} + +@mixin mixin-at-rule { + .selector-inside-mixin-at-rule { + content: 'Selector inside mixin at rule'; + } +} diff --git a/test/test.js b/test/test.js index 5f82a11..9d4afc2 100755 --- a/test/test.js +++ b/test/test.js @@ -43,6 +43,17 @@ describe(`magicImporter`, () => { }); }); + it(`should filter and convert a SASS file synchronously to CSS`, () => { + const expectedResult = fs.readFileSync(`test/files/filter-reference.css`, { + encoding: `utf8` + }); + const result = sass.renderSync({ + file: `test/files/filter.scss`, + importer: magicImporter() + }); + expect(result.css.toString()).to.equal(expectedResult); + }); + it(`should compile bootstrap`, (done) => { sass.render({ file: `test/files/bootstrap.scss`, diff --git a/yarn.lock b/yarn.lock index cd3144e..e3ba05a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -458,6 +458,12 @@ cryptiles@2.x.x: dependencies: boom "2.x.x" +css-node-extract@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/css-node-extract/-/css-node-extract-0.1.0.tgz#8ee622c1556fb87f98643375fd8a9c659c97887e" + dependencies: + postcss "^5.2.8" + css-select@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/css-select/-/css-select-1.2.0.tgz#2b3a110539c5355f1cd8d314623e870b121ec858" @@ -1702,6 +1708,13 @@ node-gyp@^3.3.1: tar "^2.0.0" which "1" +node-sass-filter-importer@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/node-sass-filter-importer/-/node-sass-filter-importer-0.1.0.tgz#72f070094d4c98f9421866cf0d4da1b7c3c4a6e5" + dependencies: + css-node-extract "^0.1.0" + postcss-scss "^0.4.0" + node-sass-glob-importer@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/node-sass-glob-importer/-/node-sass-glob-importer-3.0.0.tgz#a7845727ebd42c782f8fe57adc2ef066fb5c648a" @@ -1941,9 +1954,15 @@ postcss-scss@^0.3.1: dependencies: postcss "^5.2.4" -postcss@^5.2.4, postcss@^5.2.6: - version "5.2.6" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.6.tgz#a252cd67cd52585035f17e9ad12b35137a7bdd9e" +postcss-scss@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/postcss-scss/-/postcss-scss-0.4.0.tgz#087c052c529b9270d9580bd1248a0f93d3b40d57" + dependencies: + postcss "^5.2.5" + +postcss@^5.2.4, postcss@^5.2.5, postcss@^5.2.6, postcss@^5.2.8: + version "5.2.8" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.8.tgz#05720c49df23c79bda51fd01daeb1e9222e94390" dependencies: chalk "^1.1.3" js-base64 "^2.1.9" From ce620f42eba73f366af4793b90aa93fee5eacd7f Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Mon, 9 Jan 2017 16:37:45 +0100 Subject: [PATCH 03/23] Add gulp usage example to the README, fixes #77 --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index ed89ed8..9931482 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,19 @@ sass.render({ }); ``` +### Gulp +```node +var gulp = require('gulp'); +var sass = require('gulp-sass'); +var magicImporter = require('node-sass-magic-importer'); + +gulp.task('sass', function () { + return gulp.src('./**/*.scss') + .pipe(sass({ importer: magicImporter() }).on('error', sass.logError)) + .pipe(gulp.dest('./css')); +}); +``` + ### CLI ```bash node-sass --importer node_modules/node-sass-magic-importer/dist/cli.js -o dist src/index.scss From 0bd80f9a477a9e1883017076dffe5ba335ecd2ef Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Mon, 9 Jan 2017 19:27:13 +0100 Subject: [PATCH 04/23] Update node-sass-selector-importer to fix a problem with resolving paths when importing via CLI. --- dist/MagicImporter.js | 17 ++++++++++------- dist/cli.js | 17 ++++++++++------- dist/index.js | 17 ++++++++++------- package.json | 2 +- yarn.lock | 6 +++--- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/dist/MagicImporter.js b/dist/MagicImporter.js index 799cfcb..2a1a74f 100644 --- a/dist/MagicImporter.js +++ b/dist/MagicImporter.js @@ -12,6 +12,8 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +// @TODO: Add README info about filter importing. + /** * Selector specific imports, module importing, * globbing support, import files only once. @@ -74,22 +76,23 @@ MagicImporter.prototype.store = function store (url, selectorFilters) { var this$1 = this; if ( selectorFilters === void 0 ) selectorFilters = null; + // @TODO: Add filter logic. var absoluteUrl = this.getAbsoluteUrl(url); // URL is not in store: store and load the URL. if (this.onceStore[absoluteUrl] === undefined) { this.onceStore[absoluteUrl] = selectorFilters; return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } // URL is in store without filters, filters given: load the URL. if (this.onceStore[absoluteUrl] === null && selectorFilters) { // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); + console.warn(("Warning: double import of file \"" + url + "\"")); return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } - // URL and filters in store, URL without filters given: + // URL and filters in store, URL without filters given: // load and remove filters from store. if (this.onceStore[absoluteUrl] && !selectorFilters) { // eslint-disable-next-line no-console @@ -176,11 +179,11 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } if (filterNames) { - if (filteredContents) { + if (filteredContents) { filteredContents = CssNodeExtract.processSync({ css: filteredContents, filterNames: filterNames, - postcssSyntax: postcssSyntax + postcssSyntax: postcssSyntax }); } else { filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); @@ -205,7 +208,7 @@ MagicImporter.prototype.resolve = function resolve (url) { var this$1 = this; return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); + promiseResolve(this$1.resolveSync(url)); }); }; diff --git a/dist/cli.js b/dist/cli.js index 1a0345d..859ddcd 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -12,6 +12,8 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +// @TODO: Add README info about filter importing. + /** * Selector specific imports, module importing, * globbing support, import files only once. @@ -74,22 +76,23 @@ MagicImporter.prototype.store = function store (url, selectorFilters) { var this$1 = this; if ( selectorFilters === void 0 ) selectorFilters = null; + // @TODO: Add filter logic. var absoluteUrl = this.getAbsoluteUrl(url); // URL is not in store: store and load the URL. if (this.onceStore[absoluteUrl] === undefined) { this.onceStore[absoluteUrl] = selectorFilters; return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } // URL is in store without filters, filters given: load the URL. if (this.onceStore[absoluteUrl] === null && selectorFilters) { // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); + console.warn(("Warning: double import of file \"" + url + "\"")); return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } - // URL and filters in store, URL without filters given: + // URL and filters in store, URL without filters given: // load and remove filters from store. if (this.onceStore[absoluteUrl] && !selectorFilters) { // eslint-disable-next-line no-console @@ -176,11 +179,11 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } if (filterNames) { - if (filteredContents) { + if (filteredContents) { filteredContents = CssNodeExtract.processSync({ css: filteredContents, filterNames: filterNames, - postcssSyntax: postcssSyntax + postcssSyntax: postcssSyntax }); } else { filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); @@ -205,7 +208,7 @@ MagicImporter.prototype.resolve = function resolve (url) { var this$1 = this; return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); + promiseResolve(this$1.resolveSync(url)); }); }; diff --git a/dist/index.js b/dist/index.js index bda5941..117dbb4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12,6 +12,8 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +// @TODO: Add README info about filter importing. + /** * Selector specific imports, module importing, * globbing support, import files only once. @@ -74,22 +76,23 @@ MagicImporter.prototype.store = function store (url, selectorFilters) { var this$1 = this; if ( selectorFilters === void 0 ) selectorFilters = null; + // @TODO: Add filter logic. var absoluteUrl = this.getAbsoluteUrl(url); // URL is not in store: store and load the URL. if (this.onceStore[absoluteUrl] === undefined) { this.onceStore[absoluteUrl] = selectorFilters; return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } // URL is in store without filters, filters given: load the URL. if (this.onceStore[absoluteUrl] === null && selectorFilters) { // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); + console.warn(("Warning: double import of file \"" + url + "\"")); return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + } - // URL and filters in store, URL without filters given: + // URL and filters in store, URL without filters given: // load and remove filters from store. if (this.onceStore[absoluteUrl] && !selectorFilters) { // eslint-disable-next-line no-console @@ -176,11 +179,11 @@ MagicImporter.prototype.resolveSync = function resolveSync (url) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } if (filterNames) { - if (filteredContents) { + if (filteredContents) { filteredContents = CssNodeExtract.processSync({ css: filteredContents, filterNames: filterNames, - postcssSyntax: postcssSyntax + postcssSyntax: postcssSyntax }); } else { filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); @@ -205,7 +208,7 @@ MagicImporter.prototype.resolve = function resolve (url) { var this$1 = this; return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); + promiseResolve(this$1.resolveSync(url)); }); }; diff --git a/package.json b/package.json index b8e7465..4e1dfc7 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "node-sass-filter-importer": "^0.1.0", "node-sass-glob-importer": "^3.0.0", "node-sass-package-importer": "^3.0.1", - "node-sass-selector-importer": "^4.0.0", + "node-sass-selector-importer": "^4.2.0", "postcss-scss": "^0.4.0", "unique-concat": "^0.2.2" }, diff --git a/yarn.lock b/yarn.lock index e3ba05a..7bae8c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1728,9 +1728,9 @@ node-sass-package-importer@^3.0.1: dependencies: resolve "^1.1.7" -node-sass-selector-importer@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/node-sass-selector-importer/-/node-sass-selector-importer-4.0.0.tgz#4ec5e6b87b04e1d4c28f1c8fd1a249e7a4b7ca59" +node-sass-selector-importer@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/node-sass-selector-importer/-/node-sass-selector-importer-4.2.0.tgz#222cc502e4fb67540bad569d6984d9a03cc0695e" dependencies: css-selector-extract "^2.0.1" node-sass "^3.13.0" From 821669faef5f83f0f89c63a59b8973ad77a45381 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Mon, 9 Jan 2017 19:27:53 +0100 Subject: [PATCH 05/23] Add a test for the cli implementation, fixes #82 --- test/cli.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/cli.js diff --git a/test/cli.js b/test/cli.js new file mode 100644 index 0000000..f77535e --- /dev/null +++ b/test/cli.js @@ -0,0 +1,20 @@ +/* eslint-env node, mocha */ +const fs = require(`fs`); +const exec = require(`child_process`).exec; +const expect = require(`chai`).expect; + +/** @test {cli} **/ +describe(`cli`, () => { + it(`should convert a SASS file to CSS`, (done) => { + // eslint-disable-next-line max-len + const cmd = `node_modules/node-sass/bin/node-sass --importer dist/cli.js test/files/combined.scss`; + const expectedResult = fs.readFileSync(`test/files/combined-reference.css`, { + encoding: `utf8` + }); + exec(cmd, (error, stdout) => { + if (error) throw error; + expect(stdout.trim()).to.equal(expectedResult.trim()); + done(); + }); + }); +}); From 298521e3d657b35a8b9360959910312f9ebc8e70 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 13:30:00 +0100 Subject: [PATCH 06/23] Change gitattributes to also treat files in subdirectories of dist as binary files. --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 624dc5a..f900d1f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -dist/* binary +dist/**/* binary From 59441447a8d8bc38100f2169fa1dd49b6d854d5e Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 13:30:51 +0100 Subject: [PATCH 07/23] Use babel instead of buble and prepare for using babel to test es6 files directly. --- .babelrc | 3 + dist/MagicImporter.js | 374 +++++++++++++++-------------- dist/cli.js | 377 +++++++++++++++-------------- dist/index.js | 373 +++++++++++++++-------------- package.json | 4 +- rollup.config.js | 9 +- yarn.lock | 543 ++++++++++++++++++++++++++++++++++++++---- 7 files changed, 1097 insertions(+), 586 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..c13c5f6 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/dist/MagicImporter.js b/dist/MagicImporter.js index 2a1a74f..6d6b82c 100644 --- a/dist/MagicImporter.js +++ b/dist/MagicImporter.js @@ -12,204 +12,220 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + // @TODO: Add README info about filter importing. /** * Selector specific imports, module importing, * globbing support, import files only once. */ -var MagicImporter = function MagicImporter(options) { - if ( options === void 0 ) options = {}; - - var defaultOptions = { - cwd: process.cwd(), - includePaths: [process.cwd()], - extensions: [ - ".scss", - ".sass" - ], - packageKeys: [ - "sass", - "scss", - "style", - "css", - "main.sass", - "main.scss", - "main.style", - "main.css", - "main" - ] - }; - /** @type {Object} */ - this.options = Object.assign({}, defaultOptions, options); - /** @type {Object} */ - this.onceStore = {}; -}; -/** - * Find the absolute URL for a given relative URL. - * @param {string} url - Import url from node-sass. - * @return {string} Absolute import url. - */ -MagicImporter.prototype.getAbsoluteUrl = function getAbsoluteUrl (url) { - var absoluteUrl = url; - if (!path.isAbsolute(url)) { - this.options.includePaths.some(function (includePath) { - try { - absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); - return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} - return false; - }); - } - return absoluteUrl; -}; - -/** - * Store the given URL and selector filters - * and determine if the URL should be imported. - * @param {string} url - Import url from node-sass. - * @param {Array} selectorFilters - CSS selectors and replacement selectors. - * @return {boolean|Object} - Absolute URL and selector filters or false. - */ -MagicImporter.prototype.store = function store (url, selectorFilters) { - var this$1 = this; - if ( selectorFilters === void 0 ) selectorFilters = null; +var MagicImporter = function () { + /** + * @param {Object} options - Configuration options. + */ + function MagicImporter() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - // @TODO: Add filter logic. - var absoluteUrl = this.getAbsoluteUrl(url); + _classCallCheck(this, MagicImporter); - // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { - this.onceStore[absoluteUrl] = selectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } - - // URL is in store without filters, filters given: load the URL. - if (this.onceStore[absoluteUrl] === null && selectorFilters) { - // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } - - // URL and filters in store, URL without filters given: - // load and remove filters from store. - if (this.onceStore[absoluteUrl] && !selectorFilters) { - // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); - this.onceStore[absoluteUrl] = null; - return { url: absoluteUrl, selectorFilters: selectorFilters }; + var defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: ['.scss', '.sass'], + packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'] + }; + /** @type {Object} */ + this.options = Object.assign({}, defaultOptions, options); + /** @type {Object} */ + this.onceStore = {}; } - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - if (this.onceStore[absoluteUrl] && selectorFilters) { - var concatSelectorFilters = uniqueConcat( - this.onceStore[absoluteUrl], - selectorFilters - ); - // If stored and given selector filters are identically, do not load. - if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { - var selectorFiltersDiff = selectorFilters.filter(function (x) { return !this$1.onceStore[absoluteUrl].some(function (y) { return JSON.stringify(x) === JSON.stringify(y); }); } - ); - this.onceStore[absoluteUrl] = concatSelectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + /** + * Find the absolute URL for a given relative URL. + * @param {string} url - Import url from node-sass. + * @return {string} Absolute import url. + */ + + + _createClass(MagicImporter, [{ + key: 'getAbsoluteUrl', + value: function getAbsoluteUrl(url) { + var absoluteUrl = url; + if (!path.isAbsolute(url)) { + this.options.includePaths.some(function (includePath) { + try { + absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); + return fs.statSync(absoluteUrl).isFile(); + } catch (e) {} + return false; + }); + } + return absoluteUrl; } - } - return false; -}; -/** - * Synchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {string} Importer object or null. - */ -MagicImporter.prototype.resolveSync = function resolveSync (url) { - var this$1 = this; - - var data = null; - // @TODO: Ugly. - var resolvedUrl = url.split("from")[1] || url; - resolvedUrl = resolvedUrl.trim(); - - // Parse url and eventually extract filters. - var filterImporter = new FilterImporter(this.options); - var filterNames = filterImporter.parseUrl(url).filterNames; - - // Parse url and eventually extract selector filters. - var selectorImporter = new SelectorImporter(this.options); - var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; - - // Try to resolve glob pattern url. - var globImporter = new GlobImporter(this.options); - var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); - if (globFiles.length) { - return { contents: globFiles.map(function (x) { - this$1.store(x); - return fs.readFileSync(x, { encoding: "utf8" }); - }).join("\n") }; - } - - // Try to resolve a module url. - var packageImporter = new PackageImporter(this.options); - var packageImportData = packageImporter.resolveSync(resolvedUrl); - if (packageImportData) { - resolvedUrl = packageImportData.file; - data = { file: resolvedUrl }; - } + /** + * Store the given URL and selector filters + * and determine if the URL should be imported. + * @param {string} url - Import url from node-sass. + * @param {Array} selectorFilters - CSS selectors and replacement selectors. + * @return {boolean|Object} - Absolute URL and selector filters or false. + */ + + }, { + key: 'store', + value: function store(url) { + var _this = this; + + var selectorFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + // @TODO: Add filter logic. + var absoluteUrl = this.getAbsoluteUrl(url); + + // URL is not in store: store and load the URL. + if (this.onceStore[absoluteUrl] === undefined) { + this.onceStore[absoluteUrl] = selectorFilters; + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL is in store without filters, filters given: load the URL. + if (this.onceStore[absoluteUrl] === null && selectorFilters) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + url + '"'); + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL and filters in store, URL without filters given: + // load and remove filters from store. + if (this.onceStore[absoluteUrl] && !selectorFilters) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + url + '"'); + this.onceStore[absoluteUrl] = null; + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL and filters in store, URL with same and other filters given: + // only load other filters that not already are stored. + if (this.onceStore[absoluteUrl] && selectorFilters) { + var concatSelectorFilters = uniqueConcat(this.onceStore[absoluteUrl], selectorFilters); + // If stored and given selector filters are identically, do not load. + if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { + var selectorFiltersDiff = selectorFilters.filter(function (x) { + return !_this.onceStore[absoluteUrl].some(function (y) { + return JSON.stringify(x) === JSON.stringify(y); + }); + }); + this.onceStore[absoluteUrl] = concatSelectorFilters; + return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + } + } + return false; + } - var storedData = this.store(resolvedUrl, selectorFilters); + /** + * Synchronously resolve the path to a node-sass import url. + * @param {string} url - Import url from node-sass. + * @return {string} Importer object or null. + */ + + }, { + key: 'resolveSync', + value: function resolveSync(url) { + var _this2 = this; + + var data = null; + // @TODO: Ugly. + var resolvedUrl = url.split('from')[1] || url; + resolvedUrl = resolvedUrl.trim(); + + // Parse url and eventually extract filters. + var filterImporter = new FilterImporter(this.options); + var filterNames = filterImporter.parseUrl(url).filterNames; + + // Parse url and eventually extract selector filters. + var selectorImporter = new SelectorImporter(this.options); + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; + + // Try to resolve glob pattern url. + var globImporter = new GlobImporter(this.options); + var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); + if (globFiles.length) { + return { contents: globFiles.map(function (x) { + _this2.store(x); + return fs.readFileSync(x, { encoding: 'utf8' }); + }).join('\n') }; + } + + // Try to resolve a module url. + var packageImporter = new PackageImporter(this.options); + var packageImportData = packageImporter.resolveSync(resolvedUrl); + if (packageImportData) { + resolvedUrl = packageImportData.file; + data = { file: resolvedUrl }; + } + + var storedData = this.store(resolvedUrl, selectorFilters); + + // If the file is already stored and should not be loaded, + // prevent node-sass from importing the file again. + if (!storedData) { + return { + file: '', + contents: '' + }; + } + + resolvedUrl = storedData.url; + selectorFilters = storedData.selectorFilters; + + // Filter. + var filteredContents = void 0; + // @TODO: This is ugly, maybe refactor. + if (selectorFilters) { + filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + } + if (filterNames) { + if (filteredContents) { + filteredContents = CssNodeExtract.processSync({ + css: filteredContents, + filterNames: filterNames, + postcssSyntax: postcssSyntax + }); + } else { + filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + } + } + if (filteredContents) { + data = { + file: resolvedUrl, + contents: filteredContents + }; + } + + return data; + } - // If the file is already stored and should not be loaded, - // prevent node-sass from importing the file again. - if (!storedData) { - return { - file: "", - contents: "" - }; - } + /** + * Asynchronously resolve the path to a node-sass import url. + * @param {string} url - Import url from node-sass. + * @return {Promise} Promise for importer object or null. + */ - resolvedUrl = storedData.url; - selectorFilters = storedData.selectorFilters; + }, { + key: 'resolve', + value: function resolve(url) { + var _this3 = this; - // Filter. - var filteredContents; - // @TODO: This is ugly, maybe refactor. - if (selectorFilters) { - filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); - } - if (filterNames) { - if (filteredContents) { - filteredContents = CssNodeExtract.processSync({ - css: filteredContents, - filterNames: filterNames, - postcssSyntax: postcssSyntax + return new Promise(function (promiseResolve) { + promiseResolve(_this3.resolveSync(url)); }); - } else { - filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); } - } - if (filteredContents) { - data = { - file: resolvedUrl, - contents: filteredContents - }; - } - - return data; -}; - -/** - * Asynchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {Promise} Promise for importer object or null. - */ -MagicImporter.prototype.resolve = function resolve (url) { - var this$1 = this; + }]); - return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); - }); -}; + return MagicImporter; +}(); module.exports = MagicImporter; diff --git a/dist/cli.js b/dist/cli.js index 859ddcd..7500f03 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -12,205 +12,221 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + // @TODO: Add README info about filter importing. /** * Selector specific imports, module importing, * globbing support, import files only once. */ -var MagicImporter = function MagicImporter(options) { - if ( options === void 0 ) options = {}; - - var defaultOptions = { - cwd: process.cwd(), - includePaths: [process.cwd()], - extensions: [ - ".scss", - ".sass" - ], - packageKeys: [ - "sass", - "scss", - "style", - "css", - "main.sass", - "main.scss", - "main.style", - "main.css", - "main" - ] - }; - /** @type {Object} */ - this.options = Object.assign({}, defaultOptions, options); - /** @type {Object} */ - this.onceStore = {}; -}; -/** - * Find the absolute URL for a given relative URL. - * @param {string} url - Import url from node-sass. - * @return {string} Absolute import url. - */ -MagicImporter.prototype.getAbsoluteUrl = function getAbsoluteUrl (url) { - var absoluteUrl = url; - if (!path.isAbsolute(url)) { - this.options.includePaths.some(function (includePath) { - try { - absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); - return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} - return false; - }); - } - return absoluteUrl; -}; +var MagicImporter = function () { + /** + * @param {Object} options - Configuration options. + */ + function MagicImporter() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; -/** - * Store the given URL and selector filters - * and determine if the URL should be imported. - * @param {string} url - Import url from node-sass. - * @param {Array} selectorFilters - CSS selectors and replacement selectors. - * @return {boolean|Object} - Absolute URL and selector filters or false. - */ -MagicImporter.prototype.store = function store (url, selectorFilters) { - var this$1 = this; - if ( selectorFilters === void 0 ) selectorFilters = null; + _classCallCheck(this, MagicImporter); - // @TODO: Add filter logic. - var absoluteUrl = this.getAbsoluteUrl(url); - - // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { - this.onceStore[absoluteUrl] = selectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } - - // URL is in store without filters, filters given: load the URL. - if (this.onceStore[absoluteUrl] === null && selectorFilters) { - // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } - - // URL and filters in store, URL without filters given: - // load and remove filters from store. - if (this.onceStore[absoluteUrl] && !selectorFilters) { - // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); - this.onceStore[absoluteUrl] = null; - return { url: absoluteUrl, selectorFilters: selectorFilters }; + var defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: ['.scss', '.sass'], + packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'] + }; + /** @type {Object} */ + this.options = Object.assign({}, defaultOptions, options); + /** @type {Object} */ + this.onceStore = {}; } - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - if (this.onceStore[absoluteUrl] && selectorFilters) { - var concatSelectorFilters = uniqueConcat( - this.onceStore[absoluteUrl], - selectorFilters - ); - // If stored and given selector filters are identically, do not load. - if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { - var selectorFiltersDiff = selectorFilters.filter(function (x) { return !this$1.onceStore[absoluteUrl].some(function (y) { return JSON.stringify(x) === JSON.stringify(y); }); } - ); - this.onceStore[absoluteUrl] = concatSelectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + /** + * Find the absolute URL for a given relative URL. + * @param {string} url - Import url from node-sass. + * @return {string} Absolute import url. + */ + + + _createClass(MagicImporter, [{ + key: 'getAbsoluteUrl', + value: function getAbsoluteUrl(url) { + var absoluteUrl = url; + if (!path.isAbsolute(url)) { + this.options.includePaths.some(function (includePath) { + try { + absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); + return fs.statSync(absoluteUrl).isFile(); + } catch (e) {} + return false; + }); + } + return absoluteUrl; } - } - return false; -}; - -/** - * Synchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {string} Importer object or null. - */ -MagicImporter.prototype.resolveSync = function resolveSync (url) { - var this$1 = this; - - var data = null; - // @TODO: Ugly. - var resolvedUrl = url.split("from")[1] || url; - resolvedUrl = resolvedUrl.trim(); - - // Parse url and eventually extract filters. - var filterImporter = new FilterImporter(this.options); - var filterNames = filterImporter.parseUrl(url).filterNames; - - // Parse url and eventually extract selector filters. - var selectorImporter = new SelectorImporter(this.options); - var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; - - // Try to resolve glob pattern url. - var globImporter = new GlobImporter(this.options); - var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); - if (globFiles.length) { - return { contents: globFiles.map(function (x) { - this$1.store(x); - return fs.readFileSync(x, { encoding: "utf8" }); - }).join("\n") }; - } - // Try to resolve a module url. - var packageImporter = new PackageImporter(this.options); - var packageImportData = packageImporter.resolveSync(resolvedUrl); - if (packageImportData) { - resolvedUrl = packageImportData.file; - data = { file: resolvedUrl }; - } + /** + * Store the given URL and selector filters + * and determine if the URL should be imported. + * @param {string} url - Import url from node-sass. + * @param {Array} selectorFilters - CSS selectors and replacement selectors. + * @return {boolean|Object} - Absolute URL and selector filters or false. + */ + + }, { + key: 'store', + value: function store(url) { + var _this = this; + + var selectorFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + // @TODO: Add filter logic. + var absoluteUrl = this.getAbsoluteUrl(url); + + // URL is not in store: store and load the URL. + if (this.onceStore[absoluteUrl] === undefined) { + this.onceStore[absoluteUrl] = selectorFilters; + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL is in store without filters, filters given: load the URL. + if (this.onceStore[absoluteUrl] === null && selectorFilters) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + url + '"'); + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL and filters in store, URL without filters given: + // load and remove filters from store. + if (this.onceStore[absoluteUrl] && !selectorFilters) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + url + '"'); + this.onceStore[absoluteUrl] = null; + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL and filters in store, URL with same and other filters given: + // only load other filters that not already are stored. + if (this.onceStore[absoluteUrl] && selectorFilters) { + var concatSelectorFilters = uniqueConcat(this.onceStore[absoluteUrl], selectorFilters); + // If stored and given selector filters are identically, do not load. + if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { + var selectorFiltersDiff = selectorFilters.filter(function (x) { + return !_this.onceStore[absoluteUrl].some(function (y) { + return JSON.stringify(x) === JSON.stringify(y); + }); + }); + this.onceStore[absoluteUrl] = concatSelectorFilters; + return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + } + } + return false; + } - var storedData = this.store(resolvedUrl, selectorFilters); + /** + * Synchronously resolve the path to a node-sass import url. + * @param {string} url - Import url from node-sass. + * @return {string} Importer object or null. + */ + + }, { + key: 'resolveSync', + value: function resolveSync(url) { + var _this2 = this; + + var data = null; + // @TODO: Ugly. + var resolvedUrl = url.split('from')[1] || url; + resolvedUrl = resolvedUrl.trim(); + + // Parse url and eventually extract filters. + var filterImporter = new FilterImporter(this.options); + var filterNames = filterImporter.parseUrl(url).filterNames; + + // Parse url and eventually extract selector filters. + var selectorImporter = new SelectorImporter(this.options); + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; + + // Try to resolve glob pattern url. + var globImporter = new GlobImporter(this.options); + var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); + if (globFiles.length) { + return { contents: globFiles.map(function (x) { + _this2.store(x); + return fs.readFileSync(x, { encoding: 'utf8' }); + }).join('\n') }; + } + + // Try to resolve a module url. + var packageImporter = new PackageImporter(this.options); + var packageImportData = packageImporter.resolveSync(resolvedUrl); + if (packageImportData) { + resolvedUrl = packageImportData.file; + data = { file: resolvedUrl }; + } + + var storedData = this.store(resolvedUrl, selectorFilters); + + // If the file is already stored and should not be loaded, + // prevent node-sass from importing the file again. + if (!storedData) { + return { + file: '', + contents: '' + }; + } + + resolvedUrl = storedData.url; + selectorFilters = storedData.selectorFilters; + + // Filter. + var filteredContents = void 0; + // @TODO: This is ugly, maybe refactor. + if (selectorFilters) { + filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + } + if (filterNames) { + if (filteredContents) { + filteredContents = CssNodeExtract.processSync({ + css: filteredContents, + filterNames: filterNames, + postcssSyntax: postcssSyntax + }); + } else { + filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + } + } + if (filteredContents) { + data = { + file: resolvedUrl, + contents: filteredContents + }; + } + + return data; + } - // If the file is already stored and should not be loaded, - // prevent node-sass from importing the file again. - if (!storedData) { - return { - file: "", - contents: "" - }; - } + /** + * Asynchronously resolve the path to a node-sass import url. + * @param {string} url - Import url from node-sass. + * @return {Promise} Promise for importer object or null. + */ - resolvedUrl = storedData.url; - selectorFilters = storedData.selectorFilters; + }, { + key: 'resolve', + value: function resolve(url) { + var _this3 = this; - // Filter. - var filteredContents; - // @TODO: This is ugly, maybe refactor. - if (selectorFilters) { - filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); - } - if (filterNames) { - if (filteredContents) { - filteredContents = CssNodeExtract.processSync({ - css: filteredContents, - filterNames: filterNames, - postcssSyntax: postcssSyntax + return new Promise(function (promiseResolve) { + promiseResolve(_this3.resolveSync(url)); }); - } else { - filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); } - } - if (filteredContents) { - data = { - file: resolvedUrl, - contents: filteredContents - }; - } - - return data; -}; + }]); -/** - * Asynchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {Promise} Promise for importer object or null. - */ -MagicImporter.prototype.resolve = function resolve (url) { - var this$1 = this; - - return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); - }); -}; + return MagicImporter; +}(); var magicImporter = new MagicImporter(); @@ -225,8 +241,7 @@ var cli = function (url, prev) { if (path.isAbsolute(prev)) { includePaths.push(path.dirname(prev)); } - magicImporter.options.includePaths = includePaths - .concat(this.options.includePaths.split(path.delimiter)); + magicImporter.options.includePaths = includePaths.concat(this.options.includePaths.split(path.delimiter)); return magicImporter.resolveSync(url); }; diff --git a/dist/index.js b/dist/index.js index 117dbb4..3b62969 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12,212 +12,228 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + // @TODO: Add README info about filter importing. /** * Selector specific imports, module importing, * globbing support, import files only once. */ -var MagicImporter = function MagicImporter(options) { - if ( options === void 0 ) options = {}; - - var defaultOptions = { - cwd: process.cwd(), - includePaths: [process.cwd()], - extensions: [ - ".scss", - ".sass" - ], - packageKeys: [ - "sass", - "scss", - "style", - "css", - "main.sass", - "main.scss", - "main.style", - "main.css", - "main" - ] - }; - /** @type {Object} */ - this.options = Object.assign({}, defaultOptions, options); - /** @type {Object} */ - this.onceStore = {}; -}; -/** - * Find the absolute URL for a given relative URL. - * @param {string} url - Import url from node-sass. - * @return {string} Absolute import url. - */ -MagicImporter.prototype.getAbsoluteUrl = function getAbsoluteUrl (url) { - var absoluteUrl = url; - if (!path.isAbsolute(url)) { - this.options.includePaths.some(function (includePath) { - try { - absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); - return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} - return false; - }); +var MagicImporter = function () { + /** + * @param {Object} options - Configuration options. + */ + function MagicImporter() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, MagicImporter); + + var defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: ['.scss', '.sass'], + packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'] + }; + /** @type {Object} */ + this.options = Object.assign({}, defaultOptions, options); + /** @type {Object} */ + this.onceStore = {}; } - return absoluteUrl; -}; -/** - * Store the given URL and selector filters - * and determine if the URL should be imported. - * @param {string} url - Import url from node-sass. - * @param {Array} selectorFilters - CSS selectors and replacement selectors. - * @return {boolean|Object} - Absolute URL and selector filters or false. - */ -MagicImporter.prototype.store = function store (url, selectorFilters) { - var this$1 = this; - if ( selectorFilters === void 0 ) selectorFilters = null; + /** + * Find the absolute URL for a given relative URL. + * @param {string} url - Import url from node-sass. + * @return {string} Absolute import url. + */ - // @TODO: Add filter logic. - var absoluteUrl = this.getAbsoluteUrl(url); - // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { - this.onceStore[absoluteUrl] = selectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + _createClass(MagicImporter, [{ + key: 'getAbsoluteUrl', + value: function getAbsoluteUrl(url) { + var absoluteUrl = url; + if (!path.isAbsolute(url)) { + this.options.includePaths.some(function (includePath) { + try { + absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); + return fs.statSync(absoluteUrl).isFile(); + } catch (e) {} + return false; + }); + } + return absoluteUrl; + } - // URL is in store without filters, filters given: load the URL. - if (this.onceStore[absoluteUrl] === null && selectorFilters) { - // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + /** + * Store the given URL and selector filters + * and determine if the URL should be imported. + * @param {string} url - Import url from node-sass. + * @param {Array} selectorFilters - CSS selectors and replacement selectors. + * @return {boolean|Object} - Absolute URL and selector filters or false. + */ - // URL and filters in store, URL without filters given: - // load and remove filters from store. - if (this.onceStore[absoluteUrl] && !selectorFilters) { - // eslint-disable-next-line no-console - console.warn(("Warning: double import of file \"" + url + "\"")); - this.onceStore[absoluteUrl] = null; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + }, { + key: 'store', + value: function store(url) { + var _this = this; + + var selectorFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + // @TODO: Add filter logic. + var absoluteUrl = this.getAbsoluteUrl(url); + + // URL is not in store: store and load the URL. + if (this.onceStore[absoluteUrl] === undefined) { + this.onceStore[absoluteUrl] = selectorFilters; + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL is in store without filters, filters given: load the URL. + if (this.onceStore[absoluteUrl] === null && selectorFilters) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + url + '"'); + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL and filters in store, URL without filters given: + // load and remove filters from store. + if (this.onceStore[absoluteUrl] && !selectorFilters) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + url + '"'); + this.onceStore[absoluteUrl] = null; + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - if (this.onceStore[absoluteUrl] && selectorFilters) { - var concatSelectorFilters = uniqueConcat( - this.onceStore[absoluteUrl], - selectorFilters - ); - // If stored and given selector filters are identically, do not load. - if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { - var selectorFiltersDiff = selectorFilters.filter(function (x) { return !this$1.onceStore[absoluteUrl].some(function (y) { return JSON.stringify(x) === JSON.stringify(y); }); } - ); - this.onceStore[absoluteUrl] = concatSelectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + // URL and filters in store, URL with same and other filters given: + // only load other filters that not already are stored. + if (this.onceStore[absoluteUrl] && selectorFilters) { + var concatSelectorFilters = uniqueConcat(this.onceStore[absoluteUrl], selectorFilters); + // If stored and given selector filters are identically, do not load. + if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { + var selectorFiltersDiff = selectorFilters.filter(function (x) { + return !_this.onceStore[absoluteUrl].some(function (y) { + return JSON.stringify(x) === JSON.stringify(y); + }); + }); + this.onceStore[absoluteUrl] = concatSelectorFilters; + return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + } + } + return false; } - } - return false; -}; -/** - * Synchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {string} Importer object or null. - */ -MagicImporter.prototype.resolveSync = function resolveSync (url) { - var this$1 = this; - - var data = null; - // @TODO: Ugly. - var resolvedUrl = url.split("from")[1] || url; - resolvedUrl = resolvedUrl.trim(); - - // Parse url and eventually extract filters. - var filterImporter = new FilterImporter(this.options); - var filterNames = filterImporter.parseUrl(url).filterNames; - - // Parse url and eventually extract selector filters. - var selectorImporter = new SelectorImporter(this.options); - var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; - - // Try to resolve glob pattern url. - var globImporter = new GlobImporter(this.options); - var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); - if (globFiles.length) { - return { contents: globFiles.map(function (x) { - this$1.store(x); - return fs.readFileSync(x, { encoding: "utf8" }); - }).join("\n") }; - } + /** + * Synchronously resolve the path to a node-sass import url. + * @param {string} url - Import url from node-sass. + * @return {string} Importer object or null. + */ - // Try to resolve a module url. - var packageImporter = new PackageImporter(this.options); - var packageImportData = packageImporter.resolveSync(resolvedUrl); - if (packageImportData) { - resolvedUrl = packageImportData.file; - data = { file: resolvedUrl }; - } + }, { + key: 'resolveSync', + value: function resolveSync(url) { + var _this2 = this; - var storedData = this.store(resolvedUrl, selectorFilters); + var data = null; + // @TODO: Ugly. + var resolvedUrl = url.split('from')[1] || url; + resolvedUrl = resolvedUrl.trim(); - // If the file is already stored and should not be loaded, - // prevent node-sass from importing the file again. - if (!storedData) { - return { - file: "", - contents: "" - }; - } + // Parse url and eventually extract filters. + var filterImporter = new FilterImporter(this.options); + var filterNames = filterImporter.parseUrl(url).filterNames; - resolvedUrl = storedData.url; - selectorFilters = storedData.selectorFilters; + // Parse url and eventually extract selector filters. + var selectorImporter = new SelectorImporter(this.options); + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; - // Filter. - var filteredContents; - // @TODO: This is ugly, maybe refactor. - if (selectorFilters) { - filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); - } - if (filterNames) { - if (filteredContents) { - filteredContents = CssNodeExtract.processSync({ - css: filteredContents, - filterNames: filterNames, - postcssSyntax: postcssSyntax - }); - } else { - filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + // Try to resolve glob pattern url. + var globImporter = new GlobImporter(this.options); + var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); + if (globFiles.length) { + return { contents: globFiles.map(function (x) { + _this2.store(x); + return fs.readFileSync(x, { encoding: 'utf8' }); + }).join('\n') }; + } + + // Try to resolve a module url. + var packageImporter = new PackageImporter(this.options); + var packageImportData = packageImporter.resolveSync(resolvedUrl); + if (packageImportData) { + resolvedUrl = packageImportData.file; + data = { file: resolvedUrl }; + } + + var storedData = this.store(resolvedUrl, selectorFilters); + + // If the file is already stored and should not be loaded, + // prevent node-sass from importing the file again. + if (!storedData) { + return { + file: '', + contents: '' + }; + } + + resolvedUrl = storedData.url; + selectorFilters = storedData.selectorFilters; + + // Filter. + var filteredContents = void 0; + // @TODO: This is ugly, maybe refactor. + if (selectorFilters) { + filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + } + if (filterNames) { + if (filteredContents) { + filteredContents = CssNodeExtract.processSync({ + css: filteredContents, + filterNames: filterNames, + postcssSyntax: postcssSyntax + }); + } else { + filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + } + } + if (filteredContents) { + data = { + file: resolvedUrl, + contents: filteredContents + }; + } + + return data; } - } - if (filteredContents) { - data = { - file: resolvedUrl, - contents: filteredContents - }; - } - return data; -}; + /** + * Asynchronously resolve the path to a node-sass import url. + * @param {string} url - Import url from node-sass. + * @return {Promise} Promise for importer object or null. + */ -/** - * Asynchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {Promise} Promise for importer object or null. - */ -MagicImporter.prototype.resolve = function resolve (url) { - var this$1 = this; + }, { + key: 'resolve', + value: function resolve(url) { + var _this3 = this; + + return new Promise(function (promiseResolve) { + promiseResolve(_this3.resolveSync(url)); + }); + } + }]); - return new Promise(function (promiseResolve) { - promiseResolve(this$1.resolveSync(url)); - }); -}; + return MagicImporter; +}(); /** * Magic importer for node-sass * @param {Object} options - Configuration options. */ -var index = function (options) { - if ( options === void 0 ) options = {}; +var index = (function () { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var magicImporter = new MagicImporter(); /** @@ -230,13 +246,12 @@ var index = function (options) { if (path.isAbsolute(prev)) { includePaths.push(path.dirname(prev)); } - magicImporter.options.includePaths = includePaths - .concat(this.options.includePaths.split(path.delimiter)); + magicImporter.options.includePaths = includePaths.concat(this.options.includePaths.split(path.delimiter)); // Merge default with custom options. Object.assign(magicImporter.options, options); return magicImporter.resolveSync(url); }; -}; +}); module.exports = index; diff --git a/package.json b/package.json index 4e1dfc7..6ae6d2b 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,8 @@ "unique-concat": "^0.2.2" }, "devDependencies": { + "babel-core": "^6.21.0", + "babel-preset-es2015": "^6.18.0", "bootstrap": "4.0.0-alpha.3", "chai": "^3.5.0", "chai-as-promised": "^6.0.0", @@ -43,7 +45,7 @@ "node-sass": "^3.13.0", "pre-git": "^3.11.1", "rollup": "^0.36.3", - "rollup-plugin-buble": "^0.14.0" + "rollup-plugin-babel": "^2.7.1" }, "main": "dist/index.js", "jsnext:main": "js/index.js", diff --git a/rollup.config.js b/rollup.config.js index 0d7049c..b57fa00 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,7 +1,12 @@ -import buble from 'rollup-plugin-buble'; +import babel from 'rollup-plugin-babel'; export default { plugins: [ - buble() + babel({ + babelrc: false, + presets: [ + [`es2015`, { modules: false }] + ] + }) ] }; diff --git a/yarn.lock b/yarn.lock index 7bae8c3..984eecd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16,23 +16,17 @@ acorn-globals@^1.0.4: dependencies: acorn "^2.1.0" -acorn-jsx@^3.0.0, acorn-jsx@^3.0.1: +acorn-jsx@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" dependencies: acorn "^3.0.4" -acorn-object-spread@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/acorn-object-spread/-/acorn-object-spread-1.0.0.tgz#48ead0f4a8eb16995a17a0db9ffc6acaada4ba68" - dependencies: - acorn "^3.1.0" - acorn@^2.1.0, acorn@^2.4.0: version "2.7.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-2.7.0.tgz#ab6e7d9d886aaca8b085bc3312b79a198433f0e7" -acorn@^3.0.4, acorn@^3.1.0, acorn@^3.3.0: +acorn@^3.0.4: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" @@ -149,14 +143,404 @@ aws4@^1.2.1: version "1.4.1" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.4.1.tgz#fde7d5292466d230e5ee0f4e038d9dfaab08fc61" -babel-code-frame@^6.16.0: - version "6.16.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.16.0.tgz#f90e60da0862909d3ce098733b5d3987c97cb8de" +babel-code-frame@^6.16.0, babel-code-frame@^6.20.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.20.0.tgz#b968f839090f9a8bc6d41938fb96cb84f7387b26" dependencies: chalk "^1.1.0" esutils "^2.0.2" js-tokens "^2.0.0" +babel-core@6, babel-core@^6.18.0, babel-core@^6.21.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.21.0.tgz#75525480c21c803f826ef3867d22c19f080a3724" + dependencies: + babel-code-frame "^6.20.0" + babel-generator "^6.21.0" + babel-helpers "^6.16.0" + babel-messages "^6.8.0" + babel-register "^6.18.0" + babel-runtime "^6.20.0" + babel-template "^6.16.0" + babel-traverse "^6.21.0" + babel-types "^6.21.0" + babylon "^6.11.0" + convert-source-map "^1.1.0" + debug "^2.1.1" + json5 "^0.5.0" + lodash "^4.2.0" + minimatch "^3.0.2" + path-is-absolute "^1.0.0" + private "^0.1.6" + slash "^1.0.0" + source-map "^0.5.0" + +babel-generator@^6.21.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.21.0.tgz#605f1269c489a1c75deeca7ea16d43d4656c8494" + dependencies: + babel-messages "^6.8.0" + babel-runtime "^6.20.0" + babel-types "^6.21.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.2.0" + source-map "^0.5.0" + +babel-helper-call-delegate@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.18.0.tgz#05b14aafa430884b034097ef29e9f067ea4133bd" + dependencies: + babel-helper-hoist-variables "^6.18.0" + babel-runtime "^6.0.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helper-define-map@^6.18.0, babel-helper-define-map@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.18.0.tgz#8d6c85dc7fbb4c19be3de40474d18e97c3676ec2" + dependencies: + babel-helper-function-name "^6.18.0" + babel-runtime "^6.9.0" + babel-types "^6.18.0" + lodash "^4.2.0" + +babel-helper-function-name@^6.18.0, babel-helper-function-name@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.18.0.tgz#68ec71aeba1f3e28b2a6f0730190b754a9bf30e6" + dependencies: + babel-helper-get-function-arity "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helper-get-function-arity@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.18.0.tgz#a5b19695fd3f9cdfc328398b47dafcd7094f9f24" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-hoist-variables@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.18.0.tgz#a835b5ab8b46d6de9babefae4d98ea41e866b82a" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-optimise-call-expression@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.18.0.tgz#9261d0299ee1a4f08a6dd28b7b7c777348fd8f0f" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-regex@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.18.0.tgz#ae0ebfd77de86cb2f1af258e2cc20b5fe893ecc6" + dependencies: + babel-runtime "^6.9.0" + babel-types "^6.18.0" + lodash "^4.2.0" + +babel-helper-replace-supers@^6.18.0, babel-helper-replace-supers@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.18.0.tgz#28ec69877be4144dbd64f4cc3a337e89f29a924e" + dependencies: + babel-helper-optimise-call-expression "^6.18.0" + babel-messages "^6.8.0" + babel-runtime "^6.0.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helpers@^6.16.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.16.0.tgz#1095ec10d99279460553e67eb3eee9973d3867e3" + dependencies: + babel-runtime "^6.0.0" + babel-template "^6.16.0" + +babel-messages@^6.8.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.8.0.tgz#bf504736ca967e6d65ef0adb5a2a5f947c8e0eb9" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-check-es2015-constants@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.8.0.tgz#dbf024c32ed37bfda8dee1e76da02386a8d26fe7" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-arrow-functions@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.8.0.tgz#5b63afc3181bdc9a8c4d481b5a4f3f7d7fef3d9d" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.8.0.tgz#ed95d629c4b5a71ae29682b998f70d9833eb366d" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-block-scoping@^6.18.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.21.0.tgz#e840687f922e70fb2c42bb13501838c174a115ed" + dependencies: + babel-runtime "^6.20.0" + babel-template "^6.15.0" + babel-traverse "^6.21.0" + babel-types "^6.21.0" + lodash "^4.2.0" + +babel-plugin-transform-es2015-classes@^6.18.0, babel-plugin-transform-es2015-classes@^6.9.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.18.0.tgz#ffe7a17321bf83e494dcda0ae3fc72df48ffd1d9" + dependencies: + babel-helper-define-map "^6.18.0" + babel-helper-function-name "^6.18.0" + babel-helper-optimise-call-expression "^6.18.0" + babel-helper-replace-supers "^6.18.0" + babel-messages "^6.8.0" + babel-runtime "^6.9.0" + babel-template "^6.14.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-computed-properties@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.8.0.tgz#f51010fd61b3bd7b6b60a5fdfd307bb7a5279870" + dependencies: + babel-helper-define-map "^6.8.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-destructuring@^6.18.0: + version "6.19.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.19.0.tgz#ff1d911c4b3f4cab621bd66702a869acd1900533" + dependencies: + babel-runtime "^6.9.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.6.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.8.0.tgz#fd8f7f7171fc108cc1c70c3164b9f15a81c25f7d" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.8.0" + +babel-plugin-transform-es2015-for-of@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.18.0.tgz#4c517504db64bf8cfc119a6b8f177211f2028a70" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-function-name@^6.9.0: + version "6.9.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.9.0.tgz#8c135b17dbd064e5bba56ec511baaee2fca82719" + dependencies: + babel-helper-function-name "^6.8.0" + babel-runtime "^6.9.0" + babel-types "^6.9.0" + +babel-plugin-transform-es2015-literals@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.8.0.tgz#50aa2e5c7958fc2ab25d74ec117e0cc98f046468" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-modules-amd@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.18.0.tgz#49a054cbb762bdf9ae2d8a807076cfade6141e40" + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-modules-commonjs@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.18.0.tgz#c15ae5bb11b32a0abdcc98a5837baa4ee8d67bcc" + dependencies: + babel-plugin-transform-strict-mode "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.16.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-modules-systemjs@^6.18.0: + version "6.19.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.19.0.tgz#50438136eba74527efa00a5b0fefaf1dc4071da6" + dependencies: + babel-helper-hoist-variables "^6.18.0" + babel-runtime "^6.11.6" + babel-template "^6.14.0" + +babel-plugin-transform-es2015-modules-umd@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.18.0.tgz#23351770ece5c1f8e83ed67cb1d7992884491e50" + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-object-super@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.8.0.tgz#1b858740a5a4400887c23dcff6f4d56eea4a24c5" + dependencies: + babel-helper-replace-supers "^6.8.0" + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-parameters@^6.18.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.21.0.tgz#46a655e6864ef984091448cdf024d87b60b2a7d8" + dependencies: + babel-helper-call-delegate "^6.18.0" + babel-helper-get-function-arity "^6.18.0" + babel-runtime "^6.9.0" + babel-template "^6.16.0" + babel-traverse "^6.21.0" + babel-types "^6.21.0" + +babel-plugin-transform-es2015-shorthand-properties@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.18.0.tgz#e2ede3b7df47bf980151926534d1dd0cbea58f43" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-spread@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.8.0.tgz#0217f737e3b821fa5a669f187c6ed59205f05e9c" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-sticky-regex@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.8.0.tgz#e73d300a440a35d5c64f5c2a344dc236e3df47be" + dependencies: + babel-helper-regex "^6.8.0" + babel-runtime "^6.0.0" + babel-types "^6.8.0" + +babel-plugin-transform-es2015-template-literals@^6.6.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.8.0.tgz#86eb876d0a2c635da4ec048b4f7de9dfc897e66b" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.18.0.tgz#0b14c48629c90ff47a0650077f6aa699bee35798" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-unicode-regex@^6.3.13: + version "6.11.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.11.0.tgz#6298ceabaad88d50a3f4f392d8de997260f6ef2c" + dependencies: + babel-helper-regex "^6.8.0" + babel-runtime "^6.0.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-regenerator@^6.16.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.21.0.tgz#75d0c7e7f84f379358f508451c68a2c5fa5a9703" + dependencies: + regenerator-transform "0.9.8" + +babel-plugin-transform-strict-mode@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.18.0.tgz#df7cf2991fe046f44163dcd110d5ca43bc652b9d" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-preset-es2015@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.18.0.tgz#b8c70df84ec948c43dcf2bf770e988eb7da88312" + dependencies: + babel-plugin-check-es2015-constants "^6.3.13" + babel-plugin-transform-es2015-arrow-functions "^6.3.13" + babel-plugin-transform-es2015-block-scoped-functions "^6.3.13" + babel-plugin-transform-es2015-block-scoping "^6.18.0" + babel-plugin-transform-es2015-classes "^6.18.0" + babel-plugin-transform-es2015-computed-properties "^6.3.13" + babel-plugin-transform-es2015-destructuring "^6.18.0" + babel-plugin-transform-es2015-duplicate-keys "^6.6.0" + babel-plugin-transform-es2015-for-of "^6.18.0" + babel-plugin-transform-es2015-function-name "^6.9.0" + babel-plugin-transform-es2015-literals "^6.3.13" + babel-plugin-transform-es2015-modules-amd "^6.18.0" + babel-plugin-transform-es2015-modules-commonjs "^6.18.0" + babel-plugin-transform-es2015-modules-systemjs "^6.18.0" + babel-plugin-transform-es2015-modules-umd "^6.18.0" + babel-plugin-transform-es2015-object-super "^6.3.13" + babel-plugin-transform-es2015-parameters "^6.18.0" + babel-plugin-transform-es2015-shorthand-properties "^6.18.0" + babel-plugin-transform-es2015-spread "^6.3.13" + babel-plugin-transform-es2015-sticky-regex "^6.3.13" + babel-plugin-transform-es2015-template-literals "^6.6.0" + babel-plugin-transform-es2015-typeof-symbol "^6.18.0" + babel-plugin-transform-es2015-unicode-regex "^6.3.13" + babel-plugin-transform-regenerator "^6.16.0" + +babel-register@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.18.0.tgz#892e2e03865078dd90ad2c715111ec4449b32a68" + dependencies: + babel-core "^6.18.0" + babel-runtime "^6.11.6" + core-js "^2.4.0" + home-or-tmp "^2.0.0" + lodash "^4.2.0" + mkdirp "^0.5.1" + source-map-support "^0.4.2" + +babel-runtime@^6.0.0, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.20.0, babel-runtime@^6.9.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.20.0.tgz#87300bdcf4cd770f09bf0048c64204e17806d16f" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-template@^6.14.0, babel-template@^6.15.0, babel-template@^6.16.0, babel-template@^6.8.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.16.0.tgz#e149dd1a9f03a35f817ddbc4d0481988e7ebc8ca" + dependencies: + babel-runtime "^6.9.0" + babel-traverse "^6.16.0" + babel-types "^6.16.0" + babylon "^6.11.0" + lodash "^4.2.0" + +babel-traverse@^6.16.0, babel-traverse@^6.18.0, babel-traverse@^6.21.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.21.0.tgz#69c6365804f1a4f69eb1213f85b00a818b8c21ad" + dependencies: + babel-code-frame "^6.20.0" + babel-messages "^6.8.0" + babel-runtime "^6.20.0" + babel-types "^6.21.0" + babylon "^6.11.0" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.21.0, babel-types@^6.8.0, babel-types@^6.9.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.21.0.tgz#314b92168891ef6d3806b7f7a917fdf87c11a4b2" + dependencies: + babel-runtime "^6.20.0" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babylon@^6.11.0: + version "6.15.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" + balanced-match@^0.4.1: version "0.4.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" @@ -215,18 +599,6 @@ browser-stdout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" -buble@^0.14.0: - version "0.14.0" - resolved "https://registry.yarnpkg.com/buble/-/buble-0.14.0.tgz#f9b8005b92a5151d9eb972e3bd461ab84a6b59b9" - dependencies: - acorn "^3.3.0" - acorn-jsx "^3.0.1" - acorn-object-spread "^1.0.0" - chalk "^1.1.3" - magic-string "^0.14.0" - minimist "^1.2.0" - os-homedir "^1.0.1" - builtin-modules@^1.0.0, builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -437,10 +809,18 @@ conventional-commit-message@1.1.0: lazy-ass "1.3.0" word-wrap "1.1.0" +convert-source-map@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.3.0.tgz#e9f3e9c6e2728efc2676696a70eb382f73106a67" + core-js@0.9.18: version "0.9.18" resolved "https://registry.yarnpkg.com/core-js/-/core-js-0.9.18.tgz#13f458e430232b0f4ec1f480da7c2f5288e9d095" +core-js@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" + core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -563,6 +943,12 @@ delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + dependencies: + repeating "^2.0.0" + diff@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" @@ -1067,7 +1453,7 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^9.2.0: +globals@^9.0.0, globals@^9.2.0: version "9.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.12.0.tgz#992ce90828c3a55fa8f16fada177adb64664cf9d" @@ -1148,6 +1534,13 @@ hoek@2.x.x: version "2.16.3" resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + hosted-git-info@^2.1.4: version "2.1.5" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.1.5.tgz#0ba81d90da2e25ab34a332e6ec77936e1598118b" @@ -1269,6 +1662,12 @@ interpret@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" +invariant@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + dependencies: + loose-envify "^1.0.0" + invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" @@ -1407,6 +1806,14 @@ jsdom@^7.0.2: whatwg-url-compat "~0.6.5" xml-name-validator ">= 2.0.1 < 3.0.0" +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" @@ -1425,6 +1832,10 @@ json3@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" +json5@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + jsonfile@^2.1.0: version "2.4.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" @@ -1560,7 +1971,7 @@ lodash@3.10.1, lodash@^3.3.1: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" -lodash@^4.0.0, lodash@^4.1.0, lodash@^4.3.0: +lodash@^4.0.0, lodash@^4.1.0, lodash@^4.2.0, lodash@^4.3.0: version "4.16.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.4.tgz#01ce306b9bad1319f2a5528674f88297aeb70127" @@ -1568,6 +1979,12 @@ lodash@~4.9.0: version "4.9.0" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.9.0.tgz#4c20d742f03ce85dc700e0dd7ab9bcab85e6fc14" +loose-envify@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.0.tgz#6b26248c42f6d4fa4b0d8542f78edfcde35642a8" + dependencies: + js-tokens "^2.0.0" + loud-rejection@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" @@ -1582,12 +1999,6 @@ lru-cache@^4.0.1: pseudomap "^1.0.1" yallist "^2.0.0" -magic-string@^0.14.0: - version "0.14.0" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.14.0.tgz#57224aef1701caeed273b17a39a956e72b172462" - dependencies: - vlq "^0.2.1" - map-obj@^1.0.0, map-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" @@ -1635,7 +2046,7 @@ minimist@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.1.1.tgz#1bc2bc71658cdca5712475684363615b0b4f695b" -minimist@^1.1.3, minimist@^1.2.0: +minimist@^1.1.3: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -1855,7 +2266,7 @@ optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" -os-homedir@^1.0.0, os-homedir@^1.0.1: +os-homedir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" @@ -1865,7 +2276,7 @@ os-locale@^1.4.0: dependencies: lcid "^1.0.0" -os-tmpdir@^1.0.0: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -1992,6 +2403,10 @@ prelude-ls@~1.1.0, prelude-ls@~1.1.1, prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" +private@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.6.tgz#55c6a976d0f9bafb9924851350fe47b9b5fbb7c1" + process-nextick-args@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" @@ -2091,6 +2506,40 @@ redent@^1.0.0: indent-string "^2.1.0" strip-indent "^1.0.1" +regenerate@^1.2.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" + +regenerator-runtime@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.1.tgz#257f41961ce44558b18f7814af48c17559f9faeb" + +regenerator-transform@0.9.8: + version "0.9.8" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.9.8.tgz#0f88bb2bc03932ddb7b6b7312e68078f01026d6c" + dependencies: + babel-runtime "^6.18.0" + babel-types "^6.19.0" + private "^0.1.6" + +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + dependencies: + jsesc "~0.5.0" + repeating@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" @@ -2163,11 +2612,13 @@ rimraf@2, rimraf@^2.2.8: dependencies: glob "^7.0.5" -rollup-plugin-buble@^0.14.0: - version "0.14.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-buble/-/rollup-plugin-buble-0.14.0.tgz#3726db55fef9b9cd37cebed559cbbd4b9b2e5bc6" +rollup-plugin-babel@^2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-2.7.1.tgz#16528197b0f938a1536f44683c7a93d573182f57" dependencies: - buble "^0.14.0" + babel-core "6" + babel-plugin-transform-es2015-classes "^6.9.0" + object-assign "^4.1.0" rollup-pluginutils "^1.5.0" rollup-pluginutils@^1.5.0: @@ -2254,6 +2705,10 @@ simple-commit-message@2.1.1: semver "5.1.0" word-wrap "1.1.0" +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + slice-ansi@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" @@ -2264,13 +2719,13 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -source-map-support@^0.4.0: +source-map-support@^0.4.0, source-map-support@^0.4.2: version "0.4.3" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.3.tgz#693c8383d4389a4569486987c219744dfc601685" dependencies: source-map "^0.5.3" -source-map@^0.5.3, source-map@^0.5.6: +source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" @@ -2414,6 +2869,10 @@ through@^2.3.6: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" +to-fast-properties@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + tough-cookie@^2.2.0, tough-cookie@~2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.1.tgz#99c77dfbb7d804249e8a299d4cb0fd81fef083fd" @@ -2490,10 +2949,6 @@ verror@1.3.6: dependencies: extsprintf "1.0.2" -vlq@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.1.tgz#14439d711891e682535467f8587c5630e4222a6c" - weak-map@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/weak-map/-/weak-map-1.0.5.tgz#79691584d98607f5070bd3b70a40e6bb22e401eb" From 620e05f6a804123415fffaafdc9e2f27dc6521c5 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 13:55:48 +0100 Subject: [PATCH 08/23] Update npm dependencies. Fix compatibility issues with new versions of dependencies. Fix linting errors because of a new version of the modularis linting config. --- dist/MagicImporter.js | 17 +- dist/cli.js | 17 +- dist/index.js | 17 +- js/cli.js | 2 +- js/index.js | 2 +- js/lib/MagicImporter.js | 32 +-- package.json | 24 +- test/cli.js | 2 +- test/files/combined-reference.css | 17 +- test/test.js | 38 +-- yarn.lock | 391 +++++++++++++++++++++++------- 11 files changed, 394 insertions(+), 165 deletions(-) diff --git a/dist/MagicImporter.js b/dist/MagicImporter.js index 6d6b82c..e609010 100644 --- a/dist/MagicImporter.js +++ b/dist/MagicImporter.js @@ -7,10 +7,11 @@ var fs = _interopDefault(require('fs')); var path = _interopDefault(require('path')); var postcssSyntax = _interopDefault(require('postcss-scss')); var uniqueConcat = _interopDefault(require('unique-concat')); -var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/FilterImporter.js')); -var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter.js')); -var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); -var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); +var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); +var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter')); +var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter')); +var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter')); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); @@ -60,7 +61,7 @@ var MagicImporter = function () { try { absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} + } catch (e) {} // eslint-disable-line no-empty return false; }); } @@ -142,8 +143,7 @@ var MagicImporter = function () { resolvedUrl = resolvedUrl.trim(); // Parse url and eventually extract filters. - var filterImporter = new FilterImporter(this.options); - var filterNames = filterImporter.parseUrl(url).filterNames; + var filterNames = extractImportFilters(url); // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); @@ -187,7 +187,7 @@ var MagicImporter = function () { if (selectorFilters) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } - if (filterNames) { + if (filterNames.length) { if (filteredContents) { filteredContents = CssNodeExtract.processSync({ css: filteredContents, @@ -195,6 +195,7 @@ var MagicImporter = function () { postcssSyntax: postcssSyntax }); } else { + var filterImporter = new FilterImporter(this.options); filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); } } diff --git a/dist/cli.js b/dist/cli.js index 7500f03..56620ec 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -7,10 +7,11 @@ var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var postcssSyntax = _interopDefault(require('postcss-scss')); var uniqueConcat = _interopDefault(require('unique-concat')); -var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/FilterImporter.js')); -var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter.js')); -var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); -var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); +var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); +var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter')); +var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter')); +var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter')); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); @@ -60,7 +61,7 @@ var MagicImporter = function () { try { absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} + } catch (e) {} // eslint-disable-line no-empty return false; }); } @@ -142,8 +143,7 @@ var MagicImporter = function () { resolvedUrl = resolvedUrl.trim(); // Parse url and eventually extract filters. - var filterImporter = new FilterImporter(this.options); - var filterNames = filterImporter.parseUrl(url).filterNames; + var filterNames = extractImportFilters(url); // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); @@ -187,7 +187,7 @@ var MagicImporter = function () { if (selectorFilters) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } - if (filterNames) { + if (filterNames.length) { if (filteredContents) { filteredContents = CssNodeExtract.processSync({ css: filteredContents, @@ -195,6 +195,7 @@ var MagicImporter = function () { postcssSyntax: postcssSyntax }); } else { + var filterImporter = new FilterImporter(this.options); filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); } } diff --git a/dist/index.js b/dist/index.js index 3b62969..0045a4c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7,10 +7,11 @@ var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var postcssSyntax = _interopDefault(require('postcss-scss')); var uniqueConcat = _interopDefault(require('unique-concat')); -var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/FilterImporter.js')); -var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter.js')); -var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter.js')); -var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter.js')); +var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); +var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); +var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter')); +var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter')); +var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter')); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); @@ -60,7 +61,7 @@ var MagicImporter = function () { try { absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} + } catch (e) {} // eslint-disable-line no-empty return false; }); } @@ -142,8 +143,7 @@ var MagicImporter = function () { resolvedUrl = resolvedUrl.trim(); // Parse url and eventually extract filters. - var filterImporter = new FilterImporter(this.options); - var filterNames = filterImporter.parseUrl(url).filterNames; + var filterNames = extractImportFilters(url); // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); @@ -187,7 +187,7 @@ var MagicImporter = function () { if (selectorFilters) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } - if (filterNames) { + if (filterNames.length) { if (filteredContents) { filteredContents = CssNodeExtract.processSync({ css: filteredContents, @@ -195,6 +195,7 @@ var MagicImporter = function () { postcssSyntax: postcssSyntax }); } else { + var filterImporter = new FilterImporter(this.options); filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); } } diff --git a/js/cli.js b/js/cli.js index 283a43d..4adadc8 100644 --- a/js/cli.js +++ b/js/cli.js @@ -1,5 +1,5 @@ import path from 'path'; -import MagicImporter from './lib/MagicImporter.js'; +import MagicImporter from './lib/MagicImporter'; const magicImporter = new MagicImporter(); diff --git a/js/index.js b/js/index.js index 30b426e..f3d7323 100644 --- a/js/index.js +++ b/js/index.js @@ -1,5 +1,5 @@ import path from 'path'; -import MagicImporter from './lib/MagicImporter.js'; +import MagicImporter from './lib/MagicImporter'; /** * Magic importer for node-sass diff --git a/js/lib/MagicImporter.js b/js/lib/MagicImporter.js index a11723e..0a56a1d 100644 --- a/js/lib/MagicImporter.js +++ b/js/lib/MagicImporter.js @@ -6,10 +6,12 @@ import path from 'path'; import postcssSyntax from 'postcss-scss'; import uniqueConcat from 'unique-concat'; -import FilterImporter from 'node-sass-filter-importer/dist/lib/FilterImporter.js'; -import GlobImporter from 'node-sass-glob-importer/dist/GlobImporter.js'; -import PackageImporter from 'node-sass-package-importer/dist/PackageImporter.js'; -import SelectorImporter from 'node-sass-selector-importer/dist/SelectorImporter.js'; +import extractImportFilters from 'node-sass-filter-importer/dist/lib/extract-import-filters'; + +import FilterImporter from 'node-sass-filter-importer/dist/lib/filter-importer'; +import GlobImporter from 'node-sass-glob-importer/dist/GlobImporter'; +import PackageImporter from 'node-sass-package-importer/dist/PackageImporter'; +import SelectorImporter from 'node-sass-selector-importer/dist/SelectorImporter'; /** * Selector specific imports, module importing, @@ -25,7 +27,7 @@ export default class MagicImporter { includePaths: [process.cwd()], extensions: [ `.scss`, - `.sass` + `.sass`, ], packageKeys: [ `sass`, @@ -36,8 +38,8 @@ export default class MagicImporter { `main.scss`, `main.style`, `main.css`, - `main` - ] + `main`, + ], }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); @@ -57,7 +59,7 @@ export default class MagicImporter { try { absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} + } catch (e) {} // eslint-disable-line no-empty return false; }); } @@ -128,8 +130,7 @@ export default class MagicImporter { resolvedUrl = resolvedUrl.trim(); // Parse url and eventually extract filters. - const filterImporter = new FilterImporter(this.options); - const filterNames = filterImporter.parseUrl(url).filterNames; + const filterNames = extractImportFilters(url); // Parse url and eventually extract selector filters. const selectorImporter = new SelectorImporter(this.options); @@ -139,7 +140,7 @@ export default class MagicImporter { const globImporter = new GlobImporter(this.options); const globFiles = globImporter.resolveFilePathsSync(resolvedUrl); if (globFiles.length) { - return { contents: globFiles.map(x => { + return { contents: globFiles.map((x) => { this.store(x); return fs.readFileSync(x, { encoding: `utf8` }); }).join(`\n`) }; @@ -160,7 +161,7 @@ export default class MagicImporter { if (!storedData) { return { file: ``, - contents: `` + contents: ``, }; } @@ -173,21 +174,22 @@ export default class MagicImporter { if (selectorFilters) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } - if (filterNames) { + if (filterNames.length) { if (filteredContents) { filteredContents = CssNodeExtract.processSync({ css: filteredContents, filterNames, - postcssSyntax + postcssSyntax, }); } else { + const filterImporter = new FilterImporter(this.options); filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); } } if (filteredContents) { data = { file: resolvedUrl, - contents: filteredContents + contents: filteredContents, }; } diff --git a/package.json b/package.json index 6ae6d2b..7ecc380 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ "url": "https://github.com/maoberlehner/node-sass-magic-importer/issues" }, "dependencies": { - "css-node-extract": "^0.1.0", - "node-sass-filter-importer": "^0.1.0", - "node-sass-glob-importer": "^3.0.0", + "css-node-extract": "^0.2.1", + "node-sass-filter-importer": "^1.0.0", + "node-sass-glob-importer": "^3.0.2", "node-sass-package-importer": "^3.0.1", "node-sass-selector-importer": "^4.2.0", "postcss-scss": "^0.4.0", @@ -33,18 +33,18 @@ "devDependencies": { "babel-core": "^6.21.0", "babel-preset-es2015": "^6.18.0", - "bootstrap": "4.0.0-alpha.3", + "bootstrap": "4.0.0-alpha.6", "chai": "^3.5.0", "chai-as-promised": "^6.0.0", - "esdoc": "^0.4.8", - "eslint": "^3.10.2", - "eslint-config-modularis": "^2.0.0", + "esdoc": "^0.5.2", + "eslint": "^3.13.1", + "eslint-config-modularis": "^4.0.0", "eslint-plugin-import": "^2.2.0", - "foundation-sites": "^6.2.4", - "mocha": "^3.1.2", - "node-sass": "^3.13.0", - "pre-git": "^3.11.1", - "rollup": "^0.36.3", + "foundation-sites": "^6.3.0", + "mocha": "^3.2.0", + "node-sass": "^4.3.0", + "pre-git": "^3.12.0", + "rollup": "^0.41.3", "rollup-plugin-babel": "^2.7.1" }, "main": "dist/index.js", diff --git a/test/cli.js b/test/cli.js index f77535e..f696b8a 100644 --- a/test/cli.js +++ b/test/cli.js @@ -9,7 +9,7 @@ describe(`cli`, () => { // eslint-disable-next-line max-len const cmd = `node_modules/node-sass/bin/node-sass --importer dist/cli.js test/files/combined.scss`; const expectedResult = fs.readFileSync(`test/files/combined-reference.css`, { - encoding: `utf8` + encoding: `utf8`, }); exec(cmd, (error, stdout) => { if (error) throw error; diff --git a/test/files/combined-reference.css b/test/files/combined-reference.css index 76dfecd..041e32e 100644 --- a/test/files/combined-reference.css +++ b/test/files/combined-reference.css @@ -39,7 +39,7 @@ margin-bottom: 2rem; background-color: #eceeef; border-radius: 0.3rem; } - @media (min-width: 544px) { + @media (min-width: 576px) { .jumbotron { padding: 4rem 2rem; } } @@ -52,7 +52,7 @@ border-radius: 0; } .alert { - padding: 15px; + padding: 0.75rem 1.25rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 0.25rem; } @@ -60,10 +60,9 @@ .alert-link { font-weight: bold; } -.alert--dismissible { - padding-right: 35px; } - .alert--dismissible .alert__close { - position: relative; - top: -2px; - right: -21px; - color: inherit; } +.alert--dismissible .alert__close { + position: relative; + top: -0.75rem; + right: -1.25rem; + padding: 0.75rem 1.25rem; + color: inherit; } diff --git a/test/test.js b/test/test.js index 9d4afc2..934f822 100755 --- a/test/test.js +++ b/test/test.js @@ -17,22 +17,22 @@ describe(`magicImporter`, () => { it(`should convert a SASS file synchronously to CSS`, () => { const expectedResult = fs.readFileSync(`test/files/combined-reference.css`, { - encoding: `utf8` + encoding: `utf8`, }); const result = sass.renderSync({ file: `test/files/combined.scss`, - importer: magicImporter() + importer: magicImporter(), }); expect(result.css.toString()).to.equal(expectedResult); }); it(`should convert a SASS file asynchronously to CSS`, (done) => { const expectedResult = fs.readFileSync(`test/files/combined-reference.css`, { - encoding: `utf8` + encoding: `utf8`, }); sass.render({ file: `test/files/combined.scss`, - importer: magicImporter() + importer: magicImporter(), }, (error, result) => { if (!error) { expect(result.css.toString()).to.equal(expectedResult); @@ -45,11 +45,11 @@ describe(`magicImporter`, () => { it(`should filter and convert a SASS file synchronously to CSS`, () => { const expectedResult = fs.readFileSync(`test/files/filter-reference.css`, { - encoding: `utf8` + encoding: `utf8`, }); const result = sass.renderSync({ file: `test/files/filter.scss`, - importer: magicImporter() + importer: magicImporter(), }); expect(result.css.toString()).to.equal(expectedResult); }); @@ -57,7 +57,7 @@ describe(`magicImporter`, () => { it(`should compile bootstrap`, (done) => { sass.render({ file: `test/files/bootstrap.scss`, - importer: magicImporter() + importer: magicImporter(), }, (error) => { if (!error) { done(); @@ -70,7 +70,7 @@ describe(`magicImporter`, () => { it(`should compile bootstrap imported with alternative prefix`, (done) => { sass.render({ file: `test/files/bootstrap-alt-prefix.scss`, - importer: magicImporter({ prefix: `+` }) + importer: magicImporter({ prefix: `+` }), }, (error) => { if (!error) { done(); @@ -83,7 +83,7 @@ describe(`magicImporter`, () => { it(`should compile foundation`, (done) => { sass.render({ file: `test/files/foundation.scss`, - importer: magicImporter() + importer: magicImporter(), }, (error) => { if (!error) { done(); @@ -148,11 +148,11 @@ describe(`MagicImporter`, () => { const url = `/some/random/url.scss`; const selectorFilters = [ [`.selector-a`], - [`.selector-b`] + [`.selector-b`], ]; const expectedResult = { url, - selectorFilters + selectorFilters, }; magicImporterInstance.onceStore = {}; @@ -169,11 +169,11 @@ describe(`MagicImporter`, () => { const selectorFilters = null; const storedSelectorFilters = [ [`.selector-a`], - [`.selector-b`] + [`.selector-b`], ]; const expectedResult = { url, - selectorFilters + selectorFilters, }; const expectedOnceStoreState = {}; expectedOnceStoreState[url] = null; @@ -196,25 +196,25 @@ describe(`MagicImporter`, () => { const selectorFilters = [ [`.selector-a`], [`.selector-c`], - [`.selector-d`] + [`.selector-d`], ]; const expectedSelectorFilters = [ [`.selector-c`], - [`.selector-d`] + [`.selector-d`], ]; const storedSelectorFilters = [ [`.selector-a`], - [`.selector-b`] + [`.selector-b`], ]; const expectedStoredSelectorFilters = [ [`.selector-a`], [`.selector-b`], [`.selector-c`], - [`.selector-d`] + [`.selector-d`], ]; const expectedResult = { url, - selectorFilters: expectedSelectorFilters + selectorFilters: expectedSelectorFilters, }; const expectedOnceStoreState = {}; expectedOnceStoreState[url] = expectedStoredSelectorFilters; @@ -235,7 +235,7 @@ describe(`MagicImporter`, () => { const url = `/some/random/url.scss`; const selectorFilters = [ [`.selector-a`], - [`.selector-b`] + [`.selector-b`], ]; const storedSelectorFilters = selectorFilters; const expectedResult = false; diff --git a/yarn.lock b/yarn.lock index 984eecd..7caa6fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -143,7 +143,7 @@ aws4@^1.2.1: version "1.4.1" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.4.1.tgz#fde7d5292466d230e5ee0f4e038d9dfaab08fc61" -babel-code-frame@^6.16.0, babel-code-frame@^6.20.0: +babel-code-frame@^6.16.0, babel-code-frame@^6.20.0, babel-code-frame@^6.8.0: version "6.20.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.20.0.tgz#b968f839090f9a8bc6d41938fb96cb84f7387b26" dependencies: @@ -175,6 +175,17 @@ babel-core@6, babel-core@^6.18.0, babel-core@^6.21.0: slash "^1.0.0" source-map "^0.5.0" +babel-generator@6.11.4: + version "6.11.4" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.11.4.tgz#14f6933abb20c62666d27e3b7b9f5b9dc0712a9a" + dependencies: + babel-messages "^6.8.0" + babel-runtime "^6.9.0" + babel-types "^6.10.2" + detect-indent "^3.0.1" + lodash "^4.2.0" + source-map "^0.5.0" + babel-generator@^6.21.0: version "6.21.0" resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.21.0.tgz#605f1269c489a1c75deeca7ea16d43d4656c8494" @@ -514,6 +525,20 @@ babel-template@^6.14.0, babel-template@^6.15.0, babel-template@^6.16.0, babel-te babylon "^6.11.0" lodash "^4.2.0" +babel-traverse@6.12.0: + version "6.12.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.12.0.tgz#f22f54fa0d6eeb7f63585246bab6e637858f5d94" + dependencies: + babel-code-frame "^6.8.0" + babel-messages "^6.8.0" + babel-runtime "^6.9.0" + babel-types "^6.9.0" + babylon "^6.7.0" + debug "^2.2.0" + globals "^8.3.0" + invariant "^2.2.0" + lodash "^4.2.0" + babel-traverse@^6.16.0, babel-traverse@^6.18.0, babel-traverse@^6.21.0: version "6.21.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.21.0.tgz#69c6365804f1a4f69eb1213f85b00a818b8c21ad" @@ -528,7 +553,7 @@ babel-traverse@^6.16.0, babel-traverse@^6.18.0, babel-traverse@^6.21.0: invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.21.0, babel-types@^6.8.0, babel-types@^6.9.0: +babel-types@^6.10.2, babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.21.0, babel-types@^6.8.0, babel-types@^6.9.0: version "6.21.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.21.0.tgz#314b92168891ef6d3806b7f7a917fdf87c11a4b2" dependencies: @@ -537,7 +562,11 @@ babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.21 lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^6.11.0: +babylon@6.14.1: + version "6.14.1" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.14.1.tgz#956275fab72753ad9b3435d7afe58f8bf0a29815" + +babylon@^6.11.0, babylon@^6.7.0: version "6.15.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" @@ -571,6 +600,10 @@ bluebird@3.3.4: version "3.3.4" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.3.4.tgz#f780fe43e1a7a6510f67abd7d0d79533a40ddde6" +bluebird@3.4.6: + version "3.4.6" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.6.tgz#01da8d821d87813d158967e743d5fe6c62cf8c0f" + boolbase@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" @@ -581,12 +614,12 @@ boom@2.x.x: dependencies: hoek "2.x.x" -bootstrap@4.0.0-alpha.3: - version "4.0.0-alpha.3" - resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.0.0-alpha.3.tgz#a652d9faacd3c7436fcb7a9727fa6e0ab218979e" +bootstrap@4.0.0-alpha.6: + version "4.0.0-alpha.6" + resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.0.0-alpha.6.tgz#4f54dd33ac0deac3b28407bc2df7ec608869c9c8" dependencies: - jquery "1.9.1 - 3" - tether "^1.1.1" + jquery ">=1.9.1" + tether "^1.4.0" brace-expansion@^1.0.0: version "1.1.6" @@ -686,6 +719,10 @@ check-more-types@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.2.0.tgz#f5e2af8345d0aae617c4e3446e65fa353c7f46bb" +check-more-types@2.23.0: + version "2.23.0" + resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.23.0.tgz#6226264d30b1095aa1c0a5b874edbdd5d2d0a66f" + check-more-types@2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.3.0.tgz#b8397c69dc92a3e645f18932c045b09c74419ec4" @@ -706,6 +743,27 @@ cheerio@0.20.0: optionalDependencies: jsdom "^7.0.2" +cheerio@0.22.0: + version "0.22.0" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e" + dependencies: + css-select "~1.2.0" + dom-serializer "~0.1.0" + entities "~1.1.1" + htmlparser2 "^3.9.1" + lodash.assignin "^4.0.9" + lodash.bind "^4.1.4" + lodash.defaults "^4.0.1" + lodash.filter "^4.4.0" + lodash.flatten "^4.2.0" + lodash.foreach "^4.3.0" + lodash.map "^4.4.0" + lodash.merge "^4.4.0" + lodash.pick "^4.2.1" + lodash.reduce "^4.4.0" + lodash.reject "^4.4.0" + lodash.some "^4.4.0" + circular-json@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" @@ -844,6 +902,12 @@ css-node-extract@^0.1.0: dependencies: postcss "^5.2.8" +css-node-extract@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/css-node-extract/-/css-node-extract-0.2.1.tgz#a9fc0badbff858c8de488517fa8be55be4109e6c" + dependencies: + postcss "^5.2.8" + css-select@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/css-select/-/css-select-1.2.0.tgz#2b3a110539c5355f1cd8d314623e870b121ec858" @@ -909,6 +973,12 @@ debug@2.2.0, debug@^2.1.1, debug@^2.2.0: dependencies: ms "0.7.1" +debug@2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c" + dependencies: + ms "0.7.2" + decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -943,6 +1013,14 @@ delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" +detect-indent@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-3.0.1.tgz#9dc5e5ddbceef8325764b9451b02bc6d54084f75" + dependencies: + get-stdin "^4.0.1" + minimist "^1.1.0" + repeating "^1.1.0" + detect-indent@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" @@ -953,20 +1031,13 @@ diff@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" -doctrine@1.5.0: +doctrine@1.5.0, doctrine@^1.2.2: version "1.5.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" dependencies: esutils "^2.0.2" isarray "^1.0.0" -doctrine@^1.2.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.4.0.tgz#e2db32defa752407b935b381e89f3740e469e599" - dependencies: - esutils "^2.0.2" - isarray "^1.0.0" - dom-serializer@0, dom-serializer@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" @@ -978,13 +1049,17 @@ domelementtype@1, domelementtype@~1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" -domhandler@2.3: +domelementtype@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" + +domhandler@2.3, domhandler@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.3.0.tgz#2de59a0822d5027fabff6f032c2b25a2a8abe738" dependencies: domelementtype "1" -domutils@1.5, domutils@1.5.1: +domutils@1.5, domutils@1.5.1, domutils@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" dependencies: @@ -1001,7 +1076,7 @@ entities@1.0: version "1.0.0" resolved "https://registry.yarnpkg.com/entities/-/entities-1.0.0.tgz#b2987aa3821347fcde642b24fdfc9e4fb712bf26" -entities@~1.1.1: +entities@^1.1.1, entities@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" @@ -1067,6 +1142,10 @@ escape-html@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.2.tgz#d77d32fa98e38c2f41ae85e9278e0e0e6ba1022c" +escape-html@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -1108,9 +1187,31 @@ esdoc@^0.4.8: minimist "1.1.1" taffydb "2.7.2" -eslint-config-modularis@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/eslint-config-modularis/-/eslint-config-modularis-2.0.0.tgz#a9ad74d4412eae1cae366475c96d47652cdf861c" +esdoc@^0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/esdoc/-/esdoc-0.5.2.tgz#cbfd0b20e3d1cacc23c93c328eed987e21ba0067" + dependencies: + babel-generator "6.11.4" + babel-traverse "6.12.0" + babylon "6.14.1" + cheerio "0.22.0" + color-logger "0.0.3" + escape-html "1.0.3" + fs-extra "1.0.0" + ice-cap "0.0.4" + marked "0.3.6" + minimist "1.2.0" + taffydb "2.7.2" + +eslint-config-airbnb-base@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-10.0.1.tgz#f17d4e52992c1d45d1b7713efbcd5ecd0e7e0506" + +eslint-config-modularis@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-modularis/-/eslint-config-modularis-4.0.0.tgz#93a1ad51a5885cb1871fb2f037b9bacd0cbd8325" + dependencies: + eslint-config-airbnb-base "^10.0.1" eslint-import-resolver-node@^0.2.0: version "0.2.3" @@ -1142,9 +1243,9 @@ eslint-plugin-import@^2.2.0: minimatch "^3.0.3" pkg-up "^1.0.0" -eslint@^3.10.2: - version "3.10.2" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.10.2.tgz#c9a10e8bf6e9d65651204778c503341f1eac3ce7" +eslint@^3.13.1: + version "3.13.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.13.1.tgz#564d2646b5efded85df96985332edd91a23bff25" dependencies: babel-code-frame "^6.16.0" chalk "^1.1.3" @@ -1157,7 +1258,7 @@ eslint@^3.10.2: esutils "^2.0.2" file-entry-cache "^2.0.0" glob "^7.0.3" - globals "^9.2.0" + globals "^9.14.0" ignore "^3.2.0" imurmurhash "^0.1.4" inquirer "^0.12.0" @@ -1176,7 +1277,7 @@ eslint@^3.10.2: require-uncached "^1.0.2" shelljs "^0.7.5" strip-bom "^3.0.0" - strip-json-comments "~1.0.1" + strip-json-comments "~2.0.1" table "^3.7.8" text-table "~0.2.0" user-home "^2.0.0" @@ -1303,12 +1404,12 @@ form-data@~2.0.0: combined-stream "^1.0.5" mime-types "^2.1.11" -foundation-sites@^6.2.4: - version "6.2.4" - resolved "https://registry.yarnpkg.com/foundation-sites/-/foundation-sites-6.2.4.tgz#554746c9f3d505bd5646b4dcc03f8a9941e67f7b" +foundation-sites@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/foundation-sites/-/foundation-sites-6.3.0.tgz#19b2d6e5edced8418a4a7b4a1d65287ee1c8d512" dependencies: jquery "^2.2.0" - what-input "^2.0.0" + what-input "^4.0.3" fs-extra@0.26.5: version "0.26.5" @@ -1320,6 +1421,14 @@ fs-extra@0.26.5: path-is-absolute "^1.0.0" rimraf "^2.2.8" +fs-extra@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + klaw "^1.0.0" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -1401,21 +1510,22 @@ ggit@1.10.0: quote "0.4.0" ramda "0.9.1" -ggit@1.7.1: - version "1.7.1" - resolved "https://registry.yarnpkg.com/ggit/-/ggit-1.7.1.tgz#c6b5531ff08a3a4fb3a8cf51c16b011026d77632" +ggit@1.12.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/ggit/-/ggit-1.12.0.tgz#b4f65b9df44baa7625d50c8c9ae45553f4fe1c2d" dependencies: + bluebird "3.4.6" chdir-promise "0.2.1" - check-more-types "2.2.0" + check-more-types "2.23.0" cli-table "0.3.1" colors "1.1.2" commander "2.9.0" d3-helpers "0.3.0" - debug "2.2.0" - glob "6.0.1" - lazy-ass "1.1.0" + debug "2.3.3" + glob "7.1.1" + lazy-ass "1.5.0" lodash "3.10.1" - moment "2.10.6" + moment "2.17.0" optimist "0.6.1" q "2.0.3" quote "0.4.0" @@ -1442,7 +1552,7 @@ glob@7.0.5, glob@~7.0.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1: +glob@7.1.1, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: @@ -1453,10 +1563,18 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^9.0.0, globals@^9.2.0: +globals@^8.3.0: + version "8.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-8.18.0.tgz#93d4a62bdcac38cfafafc47d6b034768cb0ffcb4" + +globals@^9.0.0: version "9.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.12.0.tgz#992ce90828c3a55fa8f16fada177adb64664cf9d" +globals@^9.14.0: + version "9.14.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034" + globby@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" @@ -1549,6 +1667,17 @@ hr@0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/hr/-/hr-0.1.3.tgz#d9aa30f5929dabfd0b65ba395938a3e184dbcafe" +htmlparser2@^3.9.1: + version "3.9.2" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" + dependencies: + domelementtype "^1.3.0" + domhandler "^2.3.0" + domutils "^1.5.1" + entities "^1.1.1" + inherits "^2.0.1" + readable-stream "^2.0.2" + htmlparser2@~3.8.1: version "3.8.3" resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.8.3.tgz#996c28b191516a8be86501a7d79757e5c70c1068" @@ -1599,7 +1728,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@~2.0.0, inherits@~2.0.1: +inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -1759,11 +1888,7 @@ jodid25519@^1.0.0: dependencies: jsbn "~0.1.0" -"jquery@1.9.1 - 3": - version "3.1.1" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.1.1.tgz#347c1c21c7e004115e0a4da32cece041fad3c8a3" - -jquery@^2.2.0: +jquery@>=1.9.1, jquery@^2.2.0: version "2.2.4" resolved "https://registry.yarnpkg.com/jquery/-/jquery-2.2.4.tgz#2c89d6889b5eac522a7eea32c14521559c6cbf02" @@ -1878,6 +2003,10 @@ lazy-ass@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/lazy-ass/-/lazy-ass-1.4.0.tgz#c4acfd59d65b9e6f25b05c439cb2f8fc2be34437" +lazy-ass@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/lazy-ass/-/lazy-ass-1.5.0.tgz#ca15be243c7c475b8565cdbfa0f9c2f374f2a01d" + lcid@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" @@ -1935,6 +2064,14 @@ lodash.assign@^4.0.3, lodash.assign@^4.0.6, lodash.assign@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" +lodash.assignin@^4.0.9: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" + +lodash.bind@^4.1.4: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" + lodash.clonedeep@^4.3.2: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" @@ -1951,6 +2088,22 @@ lodash.create@3.1.1: lodash._basecreate "^3.0.0" lodash._isiterateecall "^3.0.0" +lodash.defaults@^4.0.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" + +lodash.filter@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" + +lodash.flatten@^4.2.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" + +lodash.foreach@^4.3.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" + lodash.isarguments@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" @@ -1967,6 +2120,34 @@ lodash.keys@^3.0.0: lodash.isarguments "^3.0.0" lodash.isarray "^3.0.0" +lodash.map@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" + +lodash.merge@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5" + +lodash.mergewith@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz#150cf0a16791f5903b8891eab154609274bdea55" + +lodash.pick@^4.2.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" + +lodash.reduce@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" + +lodash.reject@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" + +lodash.some@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" + lodash@3.10.1, lodash@^3.3.1: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" @@ -2007,6 +2188,10 @@ marked@0.3.5: version "0.3.5" resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.5.tgz#4113a15ac5d7bca158a5aae07224587b9fa15b94" +marked@0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.6.tgz#b2c6c618fccece4ef86c4fc6cb8a7cbf5aeda8d7" + meow@^3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" @@ -2046,7 +2231,7 @@ minimist@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.1.1.tgz#1bc2bc71658cdca5712475684363615b0b4f695b" -minimist@^1.1.3: +minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.3: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -2056,9 +2241,9 @@ mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1: dependencies: minimist "0.0.8" -mocha@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.1.2.tgz#51f93b432bf7e1b175ffc22883ccd0be32dba6b5" +mocha@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.2.0.tgz#7dc4f45e5088075171a68896814e6ae9eb7a85e3" dependencies: browser-stdout "1.3.0" commander "2.9.0" @@ -2072,18 +2257,22 @@ mocha@^3.1.2: mkdirp "0.5.1" supports-color "3.1.2" -moment@2.10.6: - version "2.10.6" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.10.6.tgz#6cb21967c79cba7b0ca5e66644f173662b3efa77" - moment@2.12.0: version "2.12.0" resolved "https://registry.yarnpkg.com/moment/-/moment-2.12.0.tgz#dc2560d19838d6c0731b1a6afa04675264d360d6" +moment@2.17.0: + version "2.17.0" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.17.0.tgz#a4c292e02aac5ddefb29a6eed24f51938dd3b74f" + ms@0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" +ms@0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" + mute-stream@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.4.tgz#a9219960a6d5d5d046597aee51252c6655f7177e" @@ -2119,16 +2308,17 @@ node-gyp@^3.3.1: tar "^2.0.0" which "1" -node-sass-filter-importer@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/node-sass-filter-importer/-/node-sass-filter-importer-0.1.0.tgz#72f070094d4c98f9421866cf0d4da1b7c3c4a6e5" +node-sass-filter-importer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-sass-filter-importer/-/node-sass-filter-importer-1.0.0.tgz#a41846bf614dd1a840ad5d3b6f261dceb874da6e" dependencies: css-node-extract "^0.1.0" postcss-scss "^0.4.0" + unique-concat "^0.2.2" -node-sass-glob-importer@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/node-sass-glob-importer/-/node-sass-glob-importer-3.0.0.tgz#a7845727ebd42c782f8fe57adc2ef066fb5c648a" +node-sass-glob-importer@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/node-sass-glob-importer/-/node-sass-glob-importer-3.0.2.tgz#8a8e7f57a76cb33ee5e9f3da4f263f11d65316e7" dependencies: glob "^7.1.1" unique-concat "^0.2.2" @@ -2168,6 +2358,29 @@ node-sass@^3.13.0: request "^2.61.0" sass-graph "^2.1.1" +node-sass@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.3.0.tgz#d014f64595d77b26af99e9f7a7e74704d9976bda" + dependencies: + async-foreach "^0.1.3" + chalk "^1.1.1" + cross-spawn "^3.0.0" + gaze "^1.0.0" + get-stdin "^4.0.1" + glob "^7.0.3" + in-publish "^2.0.0" + lodash.assign "^4.2.0" + lodash.clonedeep "^4.3.2" + lodash.mergewith "^4.6.0" + meow "^3.7.0" + mkdirp "^0.5.1" + nan "^2.3.2" + node-gyp "^3.3.1" + npmlog "^4.0.0" + request "^2.61.0" + sass-graph "^2.1.1" + stdout-stream "^1.4.0" + node-uuid@~1.4.7: version "1.4.7" resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f" @@ -2380,9 +2593,9 @@ postcss@^5.2.4, postcss@^5.2.5, postcss@^5.2.6, postcss@^5.2.8: source-map "^0.5.6" supports-color "^3.1.2" -pre-git@^3.11.1: - version "3.11.1" - resolved "https://registry.yarnpkg.com/pre-git/-/pre-git-3.11.1.tgz#79e65963e7b1ec4afe8768b6645210f73ad1fef3" +pre-git@^3.12.0: + version "3.12.0" + resolved "https://registry.yarnpkg.com/pre-git/-/pre-git-3.12.0.tgz#8291899a15ba86f9cdaa8ca180e47096deff8dc3" dependencies: bluebird "3.3.4" chalk "1.1.3" @@ -2395,7 +2608,7 @@ pre-git@^3.11.1: lazy-ass "1.4.0" require-relative "0.8.7" shelljs "0.6.0" - simple-commit-message "2.1.1" + simple-commit-message "2.2.1" validate-commit-msg "2.5.0" word-wrap "1.1.0" @@ -2467,7 +2680,7 @@ readable-stream@1.1: isarray "0.0.1" string_decoder "~0.10.x" -"readable-stream@^2.0.0 || ^1.1.13", readable-stream@~2.0.0, readable-stream@~2.0.5: +"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@~2.0.0, readable-stream@~2.0.5: version "2.0.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" dependencies: @@ -2540,6 +2753,12 @@ regjsparser@^0.1.4: dependencies: jsesc "~0.5.0" +repeating@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-1.1.3.tgz#3d4114218877537494f97f77f9785fab810fa4ac" + dependencies: + is-finite "^1.0.0" + repeating@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" @@ -2628,9 +2847,9 @@ rollup-pluginutils@^1.5.0: estree-walker "^0.2.1" minimatch "^3.0.2" -rollup@^0.36.3: - version "0.36.3" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.36.3.tgz#c89ac479828924ff8f69c1d44541cb4ea2fc11fc" +rollup@^0.41.3: + version "0.41.3" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.41.3.tgz#7b6a5b781e3e04d7cac459b7c6d7f3f455a6883e" dependencies: source-map-support "^0.4.0" @@ -2692,16 +2911,16 @@ signal-exit@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.1.tgz#5a4c884992b63a7acd9badb7894c3ee9cfccad81" -simple-commit-message@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/simple-commit-message/-/simple-commit-message-2.1.1.tgz#bf365812160222439cb7308b488fa870cf087d15" +simple-commit-message@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/simple-commit-message/-/simple-commit-message-2.2.1.tgz#672cc734ea4a880aba2b380d1f7b0d83afd901bb" dependencies: check-more-types "2.10.0" - ggit "1.7.1" + ggit "1.12.0" hr "0.1.3" inquirer "0.11.1" inquirer-confirm "0.2.2" - lazy-ass "1.3.0" + lazy-ass "1.5.0" semver "5.1.0" word-wrap "1.1.0" @@ -2772,6 +2991,12 @@ sshpk@^1.7.0: jsbn "~0.1.0" tweetnacl "~0.14.0" +stdout-stream@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/stdout-stream/-/stdout-stream-1.4.0.tgz#a2c7c8587e54d9427ea9edb3ac3f2cd522df378b" + dependencies: + readable-stream "^2.0.1" + string-width@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -2816,9 +3041,9 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" -strip-json-comments@~1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" supports-color@3.1.2, supports-color@^3.1.2: version "3.1.2" @@ -2857,9 +3082,9 @@ tar@^2.0.0: fstream "^1.0.2" inherits "2" -tether@^1.1.1: - version "1.3.7" - resolved "https://registry.yarnpkg.com/tether/-/tether-1.3.7.tgz#65578104741694f9672c808eae04a9adae7b0304" +tether@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/tether/-/tether-1.4.0.tgz#0f9fa171f75bf58485d8149e94799d7ae74d1c1a" text-table@~0.2.0: version "0.2.0" @@ -2957,9 +3182,9 @@ webidl-conversions@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-2.0.1.tgz#3bf8258f7d318c7443c36f2e169402a1a6703506" -what-input@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/what-input/-/what-input-2.1.1.tgz#86b6e0338d670a9fd936892b8f5115c4fe0d1d0b" +what-input@^4.0.3: + version "4.0.4" + resolved "https://registry.yarnpkg.com/what-input/-/what-input-4.0.4.tgz#14bf1a8c5eb31cdc7b6e0f3d7f23739fd92367c7" whatwg-url-compat@~0.6.5: version "0.6.5" From 90656a9cf4d8f49da7c71280cd6e00c0e83fdbed Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 13:57:19 +0100 Subject: [PATCH 09/23] Update npmignore file with newly added files. --- .npmignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.npmignore b/.npmignore index 81a5945..82baf46 100644 --- a/.npmignore +++ b/.npmignore @@ -1,8 +1,13 @@ +.babelrc .editorconfig .esdocrc .eslintrc +.gitattributes +.travis.yml +CHANGELOG.md CONTRIBUTING.md rollup.config.js +yarn.lock test From 95c548ada5c4ea0eeb8002325fc47cc18db8d704 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 14:00:07 +0100 Subject: [PATCH 10/23] Change the file name of the magic importer class and move the dist file in a lib subdirectory. --- dist/lib/magic-importer.js | 232 ++++++++++++++++++ js/cli.js | 2 +- js/index.js | 2 +- .../{MagicImporter.js => magic-importer.js} | 0 package.json | 2 +- test/test.js | 2 +- 6 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 dist/lib/magic-importer.js rename js/lib/{MagicImporter.js => magic-importer.js} (100%) diff --git a/dist/lib/magic-importer.js b/dist/lib/magic-importer.js new file mode 100644 index 0000000..e609010 --- /dev/null +++ b/dist/lib/magic-importer.js @@ -0,0 +1,232 @@ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var CssNodeExtract = _interopDefault(require('css-node-extract')); +var fs = _interopDefault(require('fs')); +var path = _interopDefault(require('path')); +var postcssSyntax = _interopDefault(require('postcss-scss')); +var uniqueConcat = _interopDefault(require('unique-concat')); +var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); +var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); +var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter')); +var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter')); +var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter')); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +// @TODO: Add README info about filter importing. + +/** + * Selector specific imports, module importing, + * globbing support, import files only once. + */ + +var MagicImporter = function () { + /** + * @param {Object} options - Configuration options. + */ + function MagicImporter() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, MagicImporter); + + var defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: ['.scss', '.sass'], + packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'] + }; + /** @type {Object} */ + this.options = Object.assign({}, defaultOptions, options); + /** @type {Object} */ + this.onceStore = {}; + } + + /** + * Find the absolute URL for a given relative URL. + * @param {string} url - Import url from node-sass. + * @return {string} Absolute import url. + */ + + + _createClass(MagicImporter, [{ + key: 'getAbsoluteUrl', + value: function getAbsoluteUrl(url) { + var absoluteUrl = url; + if (!path.isAbsolute(url)) { + this.options.includePaths.some(function (includePath) { + try { + absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); + return fs.statSync(absoluteUrl).isFile(); + } catch (e) {} // eslint-disable-line no-empty + return false; + }); + } + return absoluteUrl; + } + + /** + * Store the given URL and selector filters + * and determine if the URL should be imported. + * @param {string} url - Import url from node-sass. + * @param {Array} selectorFilters - CSS selectors and replacement selectors. + * @return {boolean|Object} - Absolute URL and selector filters or false. + */ + + }, { + key: 'store', + value: function store(url) { + var _this = this; + + var selectorFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + // @TODO: Add filter logic. + var absoluteUrl = this.getAbsoluteUrl(url); + + // URL is not in store: store and load the URL. + if (this.onceStore[absoluteUrl] === undefined) { + this.onceStore[absoluteUrl] = selectorFilters; + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL is in store without filters, filters given: load the URL. + if (this.onceStore[absoluteUrl] === null && selectorFilters) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + url + '"'); + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL and filters in store, URL without filters given: + // load and remove filters from store. + if (this.onceStore[absoluteUrl] && !selectorFilters) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + url + '"'); + this.onceStore[absoluteUrl] = null; + return { url: absoluteUrl, selectorFilters: selectorFilters }; + } + + // URL and filters in store, URL with same and other filters given: + // only load other filters that not already are stored. + if (this.onceStore[absoluteUrl] && selectorFilters) { + var concatSelectorFilters = uniqueConcat(this.onceStore[absoluteUrl], selectorFilters); + // If stored and given selector filters are identically, do not load. + if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { + var selectorFiltersDiff = selectorFilters.filter(function (x) { + return !_this.onceStore[absoluteUrl].some(function (y) { + return JSON.stringify(x) === JSON.stringify(y); + }); + }); + this.onceStore[absoluteUrl] = concatSelectorFilters; + return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + } + } + return false; + } + + /** + * Synchronously resolve the path to a node-sass import url. + * @param {string} url - Import url from node-sass. + * @return {string} Importer object or null. + */ + + }, { + key: 'resolveSync', + value: function resolveSync(url) { + var _this2 = this; + + var data = null; + // @TODO: Ugly. + var resolvedUrl = url.split('from')[1] || url; + resolvedUrl = resolvedUrl.trim(); + + // Parse url and eventually extract filters. + var filterNames = extractImportFilters(url); + + // Parse url and eventually extract selector filters. + var selectorImporter = new SelectorImporter(this.options); + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; + + // Try to resolve glob pattern url. + var globImporter = new GlobImporter(this.options); + var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); + if (globFiles.length) { + return { contents: globFiles.map(function (x) { + _this2.store(x); + return fs.readFileSync(x, { encoding: 'utf8' }); + }).join('\n') }; + } + + // Try to resolve a module url. + var packageImporter = new PackageImporter(this.options); + var packageImportData = packageImporter.resolveSync(resolvedUrl); + if (packageImportData) { + resolvedUrl = packageImportData.file; + data = { file: resolvedUrl }; + } + + var storedData = this.store(resolvedUrl, selectorFilters); + + // If the file is already stored and should not be loaded, + // prevent node-sass from importing the file again. + if (!storedData) { + return { + file: '', + contents: '' + }; + } + + resolvedUrl = storedData.url; + selectorFilters = storedData.selectorFilters; + + // Filter. + var filteredContents = void 0; + // @TODO: This is ugly, maybe refactor. + if (selectorFilters) { + filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); + } + if (filterNames.length) { + if (filteredContents) { + filteredContents = CssNodeExtract.processSync({ + css: filteredContents, + filterNames: filterNames, + postcssSyntax: postcssSyntax + }); + } else { + var filterImporter = new FilterImporter(this.options); + filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); + } + } + if (filteredContents) { + data = { + file: resolvedUrl, + contents: filteredContents + }; + } + + return data; + } + + /** + * Asynchronously resolve the path to a node-sass import url. + * @param {string} url - Import url from node-sass. + * @return {Promise} Promise for importer object or null. + */ + + }, { + key: 'resolve', + value: function resolve(url) { + var _this3 = this; + + return new Promise(function (promiseResolve) { + promiseResolve(_this3.resolveSync(url)); + }); + } + }]); + + return MagicImporter; +}(); + +module.exports = MagicImporter; diff --git a/js/cli.js b/js/cli.js index 4adadc8..de34584 100644 --- a/js/cli.js +++ b/js/cli.js @@ -1,5 +1,5 @@ import path from 'path'; -import MagicImporter from './lib/MagicImporter'; +import MagicImporter from './lib/magic-importer'; const magicImporter = new MagicImporter(); diff --git a/js/index.js b/js/index.js index f3d7323..1cc8229 100644 --- a/js/index.js +++ b/js/index.js @@ -1,5 +1,5 @@ import path from 'path'; -import MagicImporter from './lib/MagicImporter'; +import MagicImporter from './lib/magic-importer'; /** * Magic importer for node-sass diff --git a/js/lib/MagicImporter.js b/js/lib/magic-importer.js similarity index 100% rename from js/lib/MagicImporter.js rename to js/lib/magic-importer.js diff --git a/package.json b/package.json index 7ecc380..aae426f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "main": "dist/index.js", "jsnext:main": "js/index.js", "scripts": { - "scripts:bundle": "rollup --config --format cjs --output dist/index.js js/index.js && rollup --config --format cjs --output dist/cli.js js/cli.js && rollup --config --format cjs --output dist/MagicImporter.js js/lib/MagicImporter.js", + "scripts:bundle": "rollup --config --format cjs --output dist/index.js js/index.js && rollup --config --format cjs --output dist/cli.js js/cli.js && rollup --config --format cjs --output dist/lib/magic-importer.js js/lib/magic-importer.js", "scripts:lint": "eslint js/* test/*", "scripts:lint-no-error": "eslint js/* test/* || exit 0", "scripts:doc": "esdoc -c .esdocrc", diff --git a/test/test.js b/test/test.js index 934f822..a4afdff 100755 --- a/test/test.js +++ b/test/test.js @@ -7,7 +7,7 @@ const fs = require(`fs`); const sass = require(`node-sass`); const magicImporter = require(`../`); -const MagicImporterClass = require(`../dist/MagicImporter.js`); +const MagicImporterClass = require(`../dist/lib/magic-importer.js`); chai.use(chaiAsPromised); From 2b6462e837afdf1c52e4cd9192827e73070d16b2 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 14:13:03 +0100 Subject: [PATCH 11/23] Split tests into multiple files and simplify the tests. Use babel to test es6 source files directly. --- package.json | 6 +- test/{cli.js => cli.test.js} | 6 +- test/index.test.js | 77 ++++++++++ test/lib/magic-importer.test.js | 171 +++++++++++++++++++++ test/test.js | 264 -------------------------------- 5 files changed, 255 insertions(+), 269 deletions(-) rename test/{cli.js => cli.test.js} (83%) create mode 100755 test/index.test.js create mode 100644 test/lib/magic-importer.test.js delete mode 100755 test/test.js diff --git a/package.json b/package.json index aae426f..1682226 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "babel-preset-es2015": "^6.18.0", "bootstrap": "4.0.0-alpha.6", "chai": "^3.5.0", - "chai-as-promised": "^6.0.0", "esdoc": "^0.5.2", "eslint": "^3.13.1", "eslint-config-modularis": "^4.0.0", @@ -55,7 +54,10 @@ "scripts:lint-no-error": "eslint js/* test/* || exit 0", "scripts:doc": "esdoc -c .esdocrc", "scripts": "npm run scripts:bundle && npm run scripts:lint-no-error", - "test": "mocha" + "test:lib": "mocha test/lib/*.test.js --compilers js:babel-core/register", + "test:index": "mocha test/index.test.js --compilers js:babel-core/register", + "test:cli": "npm run scripts:bundle && mocha test/cli.test.js --compilers js:babel-core/register", + "test": "npm run scripts:bundle && mocha test/* --compilers js:babel-core/register" }, "config": { "pre-git": { diff --git a/test/cli.js b/test/cli.test.js similarity index 83% rename from test/cli.js rename to test/cli.test.js index f696b8a..6ef8a0c 100644 --- a/test/cli.js +++ b/test/cli.test.js @@ -1,7 +1,7 @@ /* eslint-env node, mocha */ -const fs = require(`fs`); -const exec = require(`child_process`).exec; -const expect = require(`chai`).expect; +import fs from 'fs'; +import { exec } from 'child_process'; +import { expect } from 'chai'; /** @test {cli} **/ describe(`cli`, () => { diff --git a/test/index.test.js b/test/index.test.js new file mode 100755 index 0000000..f5c19c5 --- /dev/null +++ b/test/index.test.js @@ -0,0 +1,77 @@ +/* eslint-env node, mocha */ +import fs from 'fs'; +import sass from 'node-sass'; +import { expect } from 'chai'; + +import magicImporter from '../js/index'; + +/** @test {index} */ +describe(`magicImporter`, () => { + it(`should be a function`, () => expect(magicImporter).to.be.a(`function`)); + + it(`should convert a SASS file synchronously to CSS`, () => { + const expectedResult = fs.readFileSync(`test/files/combined-reference.css`, { + encoding: `utf8`, + }); + const result = sass.renderSync({ + file: `test/files/combined.scss`, + importer: magicImporter(), + }); + expect(result.css.toString()).to.equal(expectedResult); + }); + + it(`should convert a SASS file asynchronously to CSS`, (done) => { + const expectedResult = fs.readFileSync(`test/files/combined-reference.css`, { + encoding: `utf8`, + }); + sass.render({ + file: `test/files/combined.scss`, + importer: magicImporter(), + }, (error, result) => { + if (error) throw error; + expect(result.css.toString()).to.equal(expectedResult); + done(); + }); + }); + + it(`should filter and convert a SASS file synchronously to CSS`, () => { + const expectedResult = fs.readFileSync(`test/files/filter-reference.css`, { + encoding: `utf8`, + }); + const result = sass.renderSync({ + file: `test/files/filter.scss`, + importer: magicImporter(), + }); + expect(result.css.toString()).to.equal(expectedResult); + }); + + it(`should compile bootstrap`, (done) => { + sass.render({ + file: `test/files/bootstrap.scss`, + importer: magicImporter(), + }, (error) => { + if (error) throw error; + done(); + }); + }); + + it(`should compile bootstrap imported with alternative prefix`, (done) => { + sass.render({ + file: `test/files/bootstrap-alt-prefix.scss`, + importer: magicImporter({ prefix: `+` }), + }, (error) => { + if (error) throw error; + done(); + }); + }); + + it(`should compile foundation`, (done) => { + sass.render({ + file: `test/files/foundation.scss`, + importer: magicImporter(), + }, (error) => { + if (error) throw error; + done(); + }); + }); +}); diff --git a/test/lib/magic-importer.test.js b/test/lib/magic-importer.test.js new file mode 100644 index 0000000..4dbada2 --- /dev/null +++ b/test/lib/magic-importer.test.js @@ -0,0 +1,171 @@ +/* eslint-env node, mocha */ +import { expect } from 'chai'; + +import MagicImporter from '../../js/lib/magic-importer'; + +/** @test {MagicImporter} */ +describe(`MagicImporter`, () => { + it(`should be a function`, () => expect(MagicImporter).to.be.a(`function`)); + + /** @test {MagicImporter#getAbsoluteUrl} */ + describe(`getAbsoluteUrl()`, () => { + it(`should be a function`, () => { + const magicImporterInstance = new MagicImporter(); + expect(magicImporterInstance.getAbsoluteUrl).to.be.a(`function`); + }); + + it(`should return absolute URL`, () => { + const magicImporterInstance = new MagicImporter(); + const url = `test/files/combined.scss`; + const expectedResult = `${process.cwd()}/test/files/combined.scss`; + expect(magicImporterInstance.getAbsoluteUrl(url)).to.equal(expectedResult); + }); + }); + + /** @test {MagicImporter#store} */ + describe(`store()`, () => { + it(`should be a function`, () => { + const magicImporterInstance = new MagicImporter(); + expect(magicImporterInstance.store).to.be.a(`function`); + }); + + // URL is not in store: store and load the URL. + it(`should put the URL in the store`, () => { + const magicImporterInstance = new MagicImporter(); + const url = `/some/random/url.scss`; + const expectedOnceStoreState = {}; + expectedOnceStoreState[url] = null; + + magicImporterInstance.store(url); + expect(magicImporterInstance.onceStore).to.deep.equal(expectedOnceStoreState); + }); + + // URL is in store without filters, no filters given: do not load the URL. + it(`should return false`, () => { + const magicImporterInstance = new MagicImporter(); + const url = `/some/random/url.scss`; + const expectedResult = false; + + magicImporterInstance.onceStore = {}; + magicImporterInstance.onceStore[url] = null; + expect(magicImporterInstance.store(url)).to.equal(expectedResult); + }); + + // URL is in store without filters, filters given: load the URL. + it(`should return URL and selector filters in an object`, () => { + const magicImporterInstance = new MagicImporter(); + const url = `/some/random/url.scss`; + const selectorFilters = [ + [`.selector-a`], + [`.selector-b`], + ]; + const expectedResult = { + url, + selectorFilters, + }; + + magicImporterInstance.onceStore = {}; + magicImporterInstance.onceStore[url] = null; + expect(magicImporterInstance.store(url, selectorFilters)) + .to.deep.equal(expectedResult); + }); + + // URL and filters in store, URL without filters given: + // load and remove filters from store. + it(`should remove filters from stored URL and return URL in an object`, () => { + const magicImporterInstance = new MagicImporter(); + const url = `/some/random/url.scss`; + const selectorFilters = null; + const storedSelectorFilters = [ + [`.selector-a`], + [`.selector-b`], + ]; + const expectedResult = { + url, + selectorFilters, + }; + const expectedOnceStoreState = {}; + expectedOnceStoreState[url] = null; + + magicImporterInstance.onceStore = {}; + magicImporterInstance.onceStore[url] = storedSelectorFilters; + + expect(magicImporterInstance.store(url, selectorFilters)) + .to.deep.equal(expectedResult); + expect(magicImporterInstance.onceStore) + .to.deep.equal(expectedOnceStoreState); + }); + + // URL and filters in store, URL with same and other filters given: + // only load other filters that not already are stored. + it(`should return URL and concatenated selector filters in an object`, () => { + const magicImporterInstance = new MagicImporter(); + const url = `/some/random/url.scss`; + const selectorFilters = [ + [`.selector-a`], + [`.selector-c`], + [`.selector-d`], + ]; + const expectedSelectorFilters = [ + [`.selector-c`], + [`.selector-d`], + ]; + const storedSelectorFilters = [ + [`.selector-a`], + [`.selector-b`], + ]; + const expectedStoredSelectorFilters = [ + [`.selector-a`], + [`.selector-b`], + [`.selector-c`], + [`.selector-d`], + ]; + const expectedResult = { + url, + selectorFilters: expectedSelectorFilters, + }; + const expectedOnceStoreState = {}; + expectedOnceStoreState[url] = expectedStoredSelectorFilters; + + magicImporterInstance.onceStore = {}; + magicImporterInstance.onceStore[url] = storedSelectorFilters; + + expect(magicImporterInstance.store(url, selectorFilters)) + .to.deep.equal(expectedResult); + expect(magicImporterInstance.onceStore) + .to.deep.equal(expectedOnceStoreState); + }); + + // URL and filters in store, URL and same filters given: do not load. + it(`should return false`, () => { + const magicImporterInstance = new MagicImporter(); + const url = `/some/random/url.scss`; + const selectorFilters = [ + [`.selector-a`], + [`.selector-b`], + ]; + const storedSelectorFilters = selectorFilters; + const expectedResult = false; + + magicImporterInstance.onceStore = {}; + magicImporterInstance.onceStore[url] = storedSelectorFilters; + expect(magicImporterInstance.store(url, selectorFilters)).to.equal(expectedResult); + }); + }); + + /** @test {MagicImporter#resolveSync} */ + describe(`resolveSync()`, () => { + it(`should be a function`, () => { + const magicImporterInstance = new MagicImporter(); + expect(magicImporterInstance.resolveSync).to.be.a(`function`); + }); + }); + + /** @test {MagicImporter#resolve} */ + describe(`resolve()`, () => { + it(`should be a function`, () => { + const magicImporterInstance = new MagicImporter(); + expect(magicImporterInstance.resolve).to.be.a(`function`); + }); + }); +}); diff --git a/test/test.js b/test/test.js deleted file mode 100755 index a4afdff..0000000 --- a/test/test.js +++ /dev/null @@ -1,264 +0,0 @@ -/* eslint-env node, mocha */ -/* eslint-disable no-console */ -const chai = require(`chai`); -const chaiAsPromised = require(`chai-as-promised`); -const expect = require(`chai`).expect; -const fs = require(`fs`); -const sass = require(`node-sass`); - -const magicImporter = require(`../`); -const MagicImporterClass = require(`../dist/lib/magic-importer.js`); - -chai.use(chaiAsPromised); - -/** @test {index} */ -describe(`magicImporter`, () => { - it(`should be a function`, () => expect(magicImporter).to.be.a(`function`)); - - it(`should convert a SASS file synchronously to CSS`, () => { - const expectedResult = fs.readFileSync(`test/files/combined-reference.css`, { - encoding: `utf8`, - }); - const result = sass.renderSync({ - file: `test/files/combined.scss`, - importer: magicImporter(), - }); - expect(result.css.toString()).to.equal(expectedResult); - }); - - it(`should convert a SASS file asynchronously to CSS`, (done) => { - const expectedResult = fs.readFileSync(`test/files/combined-reference.css`, { - encoding: `utf8`, - }); - sass.render({ - file: `test/files/combined.scss`, - importer: magicImporter(), - }, (error, result) => { - if (!error) { - expect(result.css.toString()).to.equal(expectedResult); - done(); - } else { - console.log(error); - } - }); - }); - - it(`should filter and convert a SASS file synchronously to CSS`, () => { - const expectedResult = fs.readFileSync(`test/files/filter-reference.css`, { - encoding: `utf8`, - }); - const result = sass.renderSync({ - file: `test/files/filter.scss`, - importer: magicImporter(), - }); - expect(result.css.toString()).to.equal(expectedResult); - }); - - it(`should compile bootstrap`, (done) => { - sass.render({ - file: `test/files/bootstrap.scss`, - importer: magicImporter(), - }, (error) => { - if (!error) { - done(); - } else { - console.log(error); - } - }); - }); - - it(`should compile bootstrap imported with alternative prefix`, (done) => { - sass.render({ - file: `test/files/bootstrap-alt-prefix.scss`, - importer: magicImporter({ prefix: `+` }), - }, (error) => { - if (!error) { - done(); - } else { - console.log(error); - } - }); - }); - - it(`should compile foundation`, (done) => { - sass.render({ - file: `test/files/foundation.scss`, - importer: magicImporter(), - }, (error) => { - if (!error) { - done(); - } else { - console.log(error); - } - }); - }); -}); - -/** @test {MagicImporter} */ -describe(`MagicImporter`, () => { - it(`should be a function`, () => expect(MagicImporterClass).to.be.a(`function`)); - - /** @test {MagicImporter#getAbsoluteUrl} */ - describe(`getAbsoluteUrl()`, () => { - it(`should be a function`, () => { - const magicImporterInstance = new MagicImporterClass(); - return expect(magicImporterInstance.getAbsoluteUrl).to.be.a(`function`); - }); - - it(`should return absolute URL`, () => { - const magicImporterInstance = new MagicImporterClass(); - const url = `test/files/combined.scss`; - const expectedResult = `${process.cwd()}/test/files/combined.scss`; - return expect(magicImporterInstance.getAbsoluteUrl(url)).to.equal(expectedResult); - }); - }); - - /** @test {MagicImporter#store} */ - describe(`store()`, () => { - it(`should be a function`, () => { - const magicImporterInstance = new MagicImporterClass(); - return expect(magicImporterInstance.store).to.be.a(`function`); - }); - - // URL is not in store: store and load the URL. - it(`should put the URL in the store`, () => { - const magicImporterInstance = new MagicImporterClass(); - const url = `/some/random/url.scss`; - const expectedOnceStoreState = {}; - expectedOnceStoreState[url] = null; - - magicImporterInstance.store(url); - return expect(magicImporterInstance.onceStore).to.deep.equal(expectedOnceStoreState); - }); - - // URL is in store without filters, no filters given: do not load the URL. - it(`should return false`, () => { - const magicImporterInstance = new MagicImporterClass(); - const url = `/some/random/url.scss`; - const expectedResult = false; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = null; - return expect(magicImporterInstance.store(url)).to.equal(expectedResult); - }); - - // URL is in store without filters, filters given: load the URL. - it(`should return URL and selector filters in an object`, () => { - const magicImporterInstance = new MagicImporterClass(); - const url = `/some/random/url.scss`; - const selectorFilters = [ - [`.selector-a`], - [`.selector-b`], - ]; - const expectedResult = { - url, - selectorFilters, - }; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = null; - return expect(magicImporterInstance.store(url, selectorFilters)) - .to.deep.equal(expectedResult); - }); - - // URL and filters in store, URL without filters given: - // load and remove filters from store. - it(`should remove filters from stored URL and return URL in an object`, () => { - const magicImporterInstance = new MagicImporterClass(); - const url = `/some/random/url.scss`; - const selectorFilters = null; - const storedSelectorFilters = [ - [`.selector-a`], - [`.selector-b`], - ]; - const expectedResult = { - url, - selectorFilters, - }; - const expectedOnceStoreState = {}; - expectedOnceStoreState[url] = null; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = storedSelectorFilters; - - const resultTest = expect(magicImporterInstance.store(url, selectorFilters)) - .to.deep.equal(expectedResult); - const stateTest = expect(magicImporterInstance.onceStore) - .to.deep.equal(expectedOnceStoreState); - return resultTest && stateTest; - }); - - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - it(`should return URL and concatenated selector filters in an object`, () => { - const magicImporterInstance = new MagicImporterClass(); - const url = `/some/random/url.scss`; - const selectorFilters = [ - [`.selector-a`], - [`.selector-c`], - [`.selector-d`], - ]; - const expectedSelectorFilters = [ - [`.selector-c`], - [`.selector-d`], - ]; - const storedSelectorFilters = [ - [`.selector-a`], - [`.selector-b`], - ]; - const expectedStoredSelectorFilters = [ - [`.selector-a`], - [`.selector-b`], - [`.selector-c`], - [`.selector-d`], - ]; - const expectedResult = { - url, - selectorFilters: expectedSelectorFilters, - }; - const expectedOnceStoreState = {}; - expectedOnceStoreState[url] = expectedStoredSelectorFilters; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = storedSelectorFilters; - - const resultTest = expect(magicImporterInstance.store(url, selectorFilters)) - .to.deep.equal(expectedResult); - const stateTest = expect(magicImporterInstance.onceStore) - .to.deep.equal(expectedOnceStoreState); - return resultTest && stateTest; - }); - - // URL and filters in store, URL and same filters given: do not load. - it(`should return false`, () => { - const magicImporterInstance = new MagicImporterClass(); - const url = `/some/random/url.scss`; - const selectorFilters = [ - [`.selector-a`], - [`.selector-b`], - ]; - const storedSelectorFilters = selectorFilters; - const expectedResult = false; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = storedSelectorFilters; - return expect(magicImporterInstance.store(url, selectorFilters)).to.equal(expectedResult); - }); - }); - - /** @test {MagicImporter#resolveSync} */ - describe(`resolveSync()`, () => { - it(`should be a function`, () => { - const magicImporterInstance = new MagicImporterClass(); - return expect(magicImporterInstance.resolveSync).to.be.a(`function`); - }); - }); - - /** @test {MagicImporter#resolve} */ - describe(`resolve()`, () => { - it(`should be a function`, () => { - const magicImporterInstance = new MagicImporterClass(); - return expect(magicImporterInstance.resolve).to.be.a(`function`); - }); - }); -}); From 52c09dc1ca903d646f260878043a1d61bf9a649b Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 14:17:39 +0100 Subject: [PATCH 12/23] Simplify the CLI script. --- dist/cli.js | 39 ++++++++++++++++++++++++++------------- js/cli.js | 21 +++------------------ 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/dist/cli.js b/dist/cli.js index 56620ec..9e15434 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -229,22 +229,35 @@ var MagicImporter = function () { return MagicImporter; }(); -var magicImporter = new MagicImporter(); - /** * Magic importer for node-sass - * @param {string} url - The path in import as-is, which LibSass encountered. - * @param {string} prev - The previously resolved path. + * @param {Object} options - Configuration options. */ -var cli = function (url, prev) { - // Create an array of include paths to search for files. - var includePaths = []; - if (path.isAbsolute(prev)) { - includePaths.push(path.dirname(prev)); - } - magicImporter.options.includePaths = includePaths.concat(this.options.includePaths.split(path.delimiter)); +var importer = (function () { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return magicImporter.resolveSync(url); -}; + var magicImporter = new MagicImporter(); + /** + * @param {string} url - The path in import as-is, which LibSass encountered. + * @param {string} prev - The previously resolved path. + */ + return function importer(url, prev) { + // Create an array of include paths to search for files. + var includePaths = []; + if (path.isAbsolute(prev)) { + includePaths.push(path.dirname(prev)); + } + magicImporter.options.includePaths = includePaths.concat(this.options.includePaths.split(path.delimiter)); + + // Merge default with custom options. + Object.assign(magicImporter.options, options); + return magicImporter.resolveSync(url); + }; +}); + +/** + * CLI importer. + */ +var cli = importer(); module.exports = cli; diff --git a/js/cli.js b/js/cli.js index de34584..1dc7ffd 100644 --- a/js/cli.js +++ b/js/cli.js @@ -1,21 +1,6 @@ -import path from 'path'; -import MagicImporter from './lib/magic-importer'; - -const magicImporter = new MagicImporter(); +import importer from './index'; /** - * Magic importer for node-sass - * @param {string} url - The path in import as-is, which LibSass encountered. - * @param {string} prev - The previously resolved path. + * CLI importer. */ -export default function (url, prev) { - // Create an array of include paths to search for files. - const includePaths = []; - if (path.isAbsolute(prev)) { - includePaths.push(path.dirname(prev)); - } - magicImporter.options.includePaths = includePaths - .concat(this.options.includePaths.split(path.delimiter)); - - return magicImporter.resolveSync(url); -} +export default importer(); From 6966f4c9bb797078866fc441499840191c5a4dd5 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 14:22:07 +0100 Subject: [PATCH 13/23] Use the cleanImportUrl package from the filter importer package to get a clean resolvedUrl. --- dist/cli.js | 5 ++--- dist/index.js | 5 ++--- dist/lib/magic-importer.js | 5 ++--- js/lib/magic-importer.js | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/dist/cli.js b/dist/cli.js index 9e15434..32ee4fa 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -7,6 +7,7 @@ var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var postcssSyntax = _interopDefault(require('postcss-scss')); var uniqueConcat = _interopDefault(require('unique-concat')); +var cleanImportUrl = _interopDefault(require('node-sass-filter-importer/dist/lib/clean-import-url')); var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter')); @@ -138,9 +139,7 @@ var MagicImporter = function () { var _this2 = this; var data = null; - // @TODO: Ugly. - var resolvedUrl = url.split('from')[1] || url; - resolvedUrl = resolvedUrl.trim(); + var resolvedUrl = cleanImportUrl(url); // Parse url and eventually extract filters. var filterNames = extractImportFilters(url); diff --git a/dist/index.js b/dist/index.js index 0045a4c..04faabc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7,6 +7,7 @@ var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var postcssSyntax = _interopDefault(require('postcss-scss')); var uniqueConcat = _interopDefault(require('unique-concat')); +var cleanImportUrl = _interopDefault(require('node-sass-filter-importer/dist/lib/clean-import-url')); var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter')); @@ -138,9 +139,7 @@ var MagicImporter = function () { var _this2 = this; var data = null; - // @TODO: Ugly. - var resolvedUrl = url.split('from')[1] || url; - resolvedUrl = resolvedUrl.trim(); + var resolvedUrl = cleanImportUrl(url); // Parse url and eventually extract filters. var filterNames = extractImportFilters(url); diff --git a/dist/lib/magic-importer.js b/dist/lib/magic-importer.js index e609010..2148787 100644 --- a/dist/lib/magic-importer.js +++ b/dist/lib/magic-importer.js @@ -7,6 +7,7 @@ var fs = _interopDefault(require('fs')); var path = _interopDefault(require('path')); var postcssSyntax = _interopDefault(require('postcss-scss')); var uniqueConcat = _interopDefault(require('unique-concat')); +var cleanImportUrl = _interopDefault(require('node-sass-filter-importer/dist/lib/clean-import-url')); var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter')); @@ -138,9 +139,7 @@ var MagicImporter = function () { var _this2 = this; var data = null; - // @TODO: Ugly. - var resolvedUrl = url.split('from')[1] || url; - resolvedUrl = resolvedUrl.trim(); + var resolvedUrl = cleanImportUrl(url); // Parse url and eventually extract filters. var filterNames = extractImportFilters(url); diff --git a/js/lib/magic-importer.js b/js/lib/magic-importer.js index 0a56a1d..a2de550 100644 --- a/js/lib/magic-importer.js +++ b/js/lib/magic-importer.js @@ -6,6 +6,7 @@ import path from 'path'; import postcssSyntax from 'postcss-scss'; import uniqueConcat from 'unique-concat'; +import cleanImportUrl from 'node-sass-filter-importer/dist/lib/clean-import-url'; import extractImportFilters from 'node-sass-filter-importer/dist/lib/extract-import-filters'; import FilterImporter from 'node-sass-filter-importer/dist/lib/filter-importer'; @@ -125,9 +126,7 @@ export default class MagicImporter { */ resolveSync(url) { let data = null; - // @TODO: Ugly. - let resolvedUrl = url.split(`from`)[1] || url; - resolvedUrl = resolvedUrl.trim(); + let resolvedUrl = cleanImportUrl(url); // Parse url and eventually extract filters. const filterNames = extractImportFilters(url); From d7a772ad3a1306f18c1735ea5e7eb7819efb5993 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 18:23:17 +0100 Subject: [PATCH 14/23] Simplify the import once mechanism. Do not try to be smart about selector filters. URLs with filters are always imported, but there is a warning if the same file is imported multiple times. --- dist/cli.js | 112 +++++++++----------- dist/index.js | 112 +++++++++----------- dist/lib/magic-importer.js | 112 +++++++++----------- js/lib/magic-importer.js | 98 ++++++++--------- package.json | 3 +- test/lib/magic-importer.test.js | 179 ++++++++++---------------------- yarn.lock | 59 +++++++---- 7 files changed, 285 insertions(+), 390 deletions(-) diff --git a/dist/cli.js b/dist/cli.js index 32ee4fa..6375270 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -6,7 +6,6 @@ var path = _interopDefault(require('path')); var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var postcssSyntax = _interopDefault(require('postcss-scss')); -var uniqueConcat = _interopDefault(require('unique-concat')); var cleanImportUrl = _interopDefault(require('node-sass-filter-importer/dist/lib/clean-import-url')); var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); @@ -18,7 +17,7 @@ var _createClass = function () { function defineProperties(target, props) { for function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -// @TODO: Add README info about filter importing. +// @TODO: Add README info about filter importing and disableWarnings option. /** * Selector specific imports, module importing, @@ -38,12 +37,13 @@ var MagicImporter = function () { cwd: process.cwd(), includePaths: [process.cwd()], extensions: ['.scss', '.sass'], - packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'] + packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'], + disableWarnings: false }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); - /** @type {Object} */ - this.onceStore = {}; + /** @type {Array} */ + this.store = []; } /** @@ -70,60 +70,49 @@ var MagicImporter = function () { } /** - * Store the given URL and selector filters - * and determine if the URL should be imported. - * @param {string} url - Import url from node-sass. - * @param {Array} selectorFilters - CSS selectors and replacement selectors. - * @return {boolean|Object} - Absolute URL and selector filters or false. + * Add an URL to the store of imported URLs. + * + * @param {String} cleanUrl + * Cleaned up import url from node-sass. */ }, { - key: 'store', - value: function store(url) { - var _this = this; - - var selectorFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + key: 'storeAdd', + value: function storeAdd(cleanUrl) { + var absoluteUrl = this.getAbsoluteUrl(cleanUrl); + if (!this.store.includes(absoluteUrl)) this.store.push(absoluteUrl); + } - // @TODO: Add filter logic. - var absoluteUrl = this.getAbsoluteUrl(url); + /** + * Check if an URL is in store, add it if is not and it has no filters. + * + * @param {String} cleanUrl + * Cleaned up import url from node-sass. + * @param {Boolean} hasFilters + * Does the URL have filters or not. + * @return {boolean} + * Returns true if the URL has no filters and is already stored. + */ - // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { - this.onceStore[absoluteUrl] = selectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + }, { + key: 'isInStore', + value: function isInStore(cleanUrl) { + var hasFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - // URL is in store without filters, filters given: load the URL. - if (this.onceStore[absoluteUrl] === null && selectorFilters) { - // eslint-disable-next-line no-console - console.warn('Warning: double import of file "' + url + '"'); - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + var absoluteUrl = this.getAbsoluteUrl(cleanUrl); - // URL and filters in store, URL without filters given: - // load and remove filters from store. - if (this.onceStore[absoluteUrl] && !selectorFilters) { - // eslint-disable-next-line no-console - console.warn('Warning: double import of file "' + url + '"'); - this.onceStore[absoluteUrl] = null; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + if (!hasFilters && this.store.includes(absoluteUrl)) return true; - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - if (this.onceStore[absoluteUrl] && selectorFilters) { - var concatSelectorFilters = uniqueConcat(this.onceStore[absoluteUrl], selectorFilters); - // If stored and given selector filters are identically, do not load. - if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { - var selectorFiltersDiff = selectorFilters.filter(function (x) { - return !_this.onceStore[absoluteUrl].some(function (y) { - return JSON.stringify(x) === JSON.stringify(y); - }); - }); - this.onceStore[absoluteUrl] = concatSelectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + if (hasFilters && this.store.includes(absoluteUrl)) { + if (!this.options.disableWarnings) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + absoluteUrl + '".'); } + return false; } + + if (!hasFilters) this.storeAdd(cleanUrl); + return false; } @@ -136,7 +125,7 @@ var MagicImporter = function () { }, { key: 'resolveSync', value: function resolveSync(url) { - var _this2 = this; + var _this = this; var data = null; var resolvedUrl = cleanImportUrl(url); @@ -146,15 +135,17 @@ var MagicImporter = function () { // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); - var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters || []; + + var hasFilters = filterNames.length || selectorFilters.length; // Try to resolve glob pattern url. var globImporter = new GlobImporter(this.options); var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); if (globFiles.length) { - return { contents: globFiles.map(function (x) { - _this2.store(x); - return fs.readFileSync(x, { encoding: 'utf8' }); + return { contents: globFiles.map(function (globUrl) { + _this.storeAdd(globUrl, hasFilters); + return fs.readFileSync(globUrl, { encoding: 'utf8' }); }).join('\n') }; } @@ -166,24 +157,19 @@ var MagicImporter = function () { data = { file: resolvedUrl }; } - var storedData = this.store(resolvedUrl, selectorFilters); - // If the file is already stored and should not be loaded, // prevent node-sass from importing the file again. - if (!storedData) { + if (this.isInStore(resolvedUrl, hasFilters)) { return { file: '', contents: '' }; } - resolvedUrl = storedData.url; - selectorFilters = storedData.selectorFilters; - // Filter. var filteredContents = void 0; // @TODO: This is ugly, maybe refactor. - if (selectorFilters) { + if (selectorFilters.length) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } if (filterNames.length) { @@ -217,10 +203,10 @@ var MagicImporter = function () { }, { key: 'resolve', value: function resolve(url) { - var _this3 = this; + var _this2 = this; return new Promise(function (promiseResolve) { - promiseResolve(_this3.resolveSync(url)); + promiseResolve(_this2.resolveSync(url)); }); } }]); diff --git a/dist/index.js b/dist/index.js index 04faabc..fcbddb6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6,7 +6,6 @@ var path = _interopDefault(require('path')); var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var postcssSyntax = _interopDefault(require('postcss-scss')); -var uniqueConcat = _interopDefault(require('unique-concat')); var cleanImportUrl = _interopDefault(require('node-sass-filter-importer/dist/lib/clean-import-url')); var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); @@ -18,7 +17,7 @@ var _createClass = function () { function defineProperties(target, props) { for function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -// @TODO: Add README info about filter importing. +// @TODO: Add README info about filter importing and disableWarnings option. /** * Selector specific imports, module importing, @@ -38,12 +37,13 @@ var MagicImporter = function () { cwd: process.cwd(), includePaths: [process.cwd()], extensions: ['.scss', '.sass'], - packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'] + packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'], + disableWarnings: false }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); - /** @type {Object} */ - this.onceStore = {}; + /** @type {Array} */ + this.store = []; } /** @@ -70,60 +70,49 @@ var MagicImporter = function () { } /** - * Store the given URL and selector filters - * and determine if the URL should be imported. - * @param {string} url - Import url from node-sass. - * @param {Array} selectorFilters - CSS selectors and replacement selectors. - * @return {boolean|Object} - Absolute URL and selector filters or false. + * Add an URL to the store of imported URLs. + * + * @param {String} cleanUrl + * Cleaned up import url from node-sass. */ }, { - key: 'store', - value: function store(url) { - var _this = this; - - var selectorFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + key: 'storeAdd', + value: function storeAdd(cleanUrl) { + var absoluteUrl = this.getAbsoluteUrl(cleanUrl); + if (!this.store.includes(absoluteUrl)) this.store.push(absoluteUrl); + } - // @TODO: Add filter logic. - var absoluteUrl = this.getAbsoluteUrl(url); + /** + * Check if an URL is in store, add it if is not and it has no filters. + * + * @param {String} cleanUrl + * Cleaned up import url from node-sass. + * @param {Boolean} hasFilters + * Does the URL have filters or not. + * @return {boolean} + * Returns true if the URL has no filters and is already stored. + */ - // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { - this.onceStore[absoluteUrl] = selectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + }, { + key: 'isInStore', + value: function isInStore(cleanUrl) { + var hasFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - // URL is in store without filters, filters given: load the URL. - if (this.onceStore[absoluteUrl] === null && selectorFilters) { - // eslint-disable-next-line no-console - console.warn('Warning: double import of file "' + url + '"'); - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + var absoluteUrl = this.getAbsoluteUrl(cleanUrl); - // URL and filters in store, URL without filters given: - // load and remove filters from store. - if (this.onceStore[absoluteUrl] && !selectorFilters) { - // eslint-disable-next-line no-console - console.warn('Warning: double import of file "' + url + '"'); - this.onceStore[absoluteUrl] = null; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + if (!hasFilters && this.store.includes(absoluteUrl)) return true; - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - if (this.onceStore[absoluteUrl] && selectorFilters) { - var concatSelectorFilters = uniqueConcat(this.onceStore[absoluteUrl], selectorFilters); - // If stored and given selector filters are identically, do not load. - if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { - var selectorFiltersDiff = selectorFilters.filter(function (x) { - return !_this.onceStore[absoluteUrl].some(function (y) { - return JSON.stringify(x) === JSON.stringify(y); - }); - }); - this.onceStore[absoluteUrl] = concatSelectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + if (hasFilters && this.store.includes(absoluteUrl)) { + if (!this.options.disableWarnings) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + absoluteUrl + '".'); } + return false; } + + if (!hasFilters) this.storeAdd(cleanUrl); + return false; } @@ -136,7 +125,7 @@ var MagicImporter = function () { }, { key: 'resolveSync', value: function resolveSync(url) { - var _this2 = this; + var _this = this; var data = null; var resolvedUrl = cleanImportUrl(url); @@ -146,15 +135,17 @@ var MagicImporter = function () { // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); - var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters || []; + + var hasFilters = filterNames.length || selectorFilters.length; // Try to resolve glob pattern url. var globImporter = new GlobImporter(this.options); var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); if (globFiles.length) { - return { contents: globFiles.map(function (x) { - _this2.store(x); - return fs.readFileSync(x, { encoding: 'utf8' }); + return { contents: globFiles.map(function (globUrl) { + _this.storeAdd(globUrl, hasFilters); + return fs.readFileSync(globUrl, { encoding: 'utf8' }); }).join('\n') }; } @@ -166,24 +157,19 @@ var MagicImporter = function () { data = { file: resolvedUrl }; } - var storedData = this.store(resolvedUrl, selectorFilters); - // If the file is already stored and should not be loaded, // prevent node-sass from importing the file again. - if (!storedData) { + if (this.isInStore(resolvedUrl, hasFilters)) { return { file: '', contents: '' }; } - resolvedUrl = storedData.url; - selectorFilters = storedData.selectorFilters; - // Filter. var filteredContents = void 0; // @TODO: This is ugly, maybe refactor. - if (selectorFilters) { + if (selectorFilters.length) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } if (filterNames.length) { @@ -217,10 +203,10 @@ var MagicImporter = function () { }, { key: 'resolve', value: function resolve(url) { - var _this3 = this; + var _this2 = this; return new Promise(function (promiseResolve) { - promiseResolve(_this3.resolveSync(url)); + promiseResolve(_this2.resolveSync(url)); }); } }]); diff --git a/dist/lib/magic-importer.js b/dist/lib/magic-importer.js index 2148787..eb5475f 100644 --- a/dist/lib/magic-importer.js +++ b/dist/lib/magic-importer.js @@ -6,7 +6,6 @@ var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var path = _interopDefault(require('path')); var postcssSyntax = _interopDefault(require('postcss-scss')); -var uniqueConcat = _interopDefault(require('unique-concat')); var cleanImportUrl = _interopDefault(require('node-sass-filter-importer/dist/lib/clean-import-url')); var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); @@ -18,7 +17,7 @@ var _createClass = function () { function defineProperties(target, props) { for function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -// @TODO: Add README info about filter importing. +// @TODO: Add README info about filter importing and disableWarnings option. /** * Selector specific imports, module importing, @@ -38,12 +37,13 @@ var MagicImporter = function () { cwd: process.cwd(), includePaths: [process.cwd()], extensions: ['.scss', '.sass'], - packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'] + packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'], + disableWarnings: false }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); - /** @type {Object} */ - this.onceStore = {}; + /** @type {Array} */ + this.store = []; } /** @@ -70,60 +70,49 @@ var MagicImporter = function () { } /** - * Store the given URL and selector filters - * and determine if the URL should be imported. - * @param {string} url - Import url from node-sass. - * @param {Array} selectorFilters - CSS selectors and replacement selectors. - * @return {boolean|Object} - Absolute URL and selector filters or false. + * Add an URL to the store of imported URLs. + * + * @param {String} cleanUrl + * Cleaned up import url from node-sass. */ }, { - key: 'store', - value: function store(url) { - var _this = this; - - var selectorFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + key: 'storeAdd', + value: function storeAdd(cleanUrl) { + var absoluteUrl = this.getAbsoluteUrl(cleanUrl); + if (!this.store.includes(absoluteUrl)) this.store.push(absoluteUrl); + } - // @TODO: Add filter logic. - var absoluteUrl = this.getAbsoluteUrl(url); + /** + * Check if an URL is in store, add it if is not and it has no filters. + * + * @param {String} cleanUrl + * Cleaned up import url from node-sass. + * @param {Boolean} hasFilters + * Does the URL have filters or not. + * @return {boolean} + * Returns true if the URL has no filters and is already stored. + */ - // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { - this.onceStore[absoluteUrl] = selectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + }, { + key: 'isInStore', + value: function isInStore(cleanUrl) { + var hasFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - // URL is in store without filters, filters given: load the URL. - if (this.onceStore[absoluteUrl] === null && selectorFilters) { - // eslint-disable-next-line no-console - console.warn('Warning: double import of file "' + url + '"'); - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + var absoluteUrl = this.getAbsoluteUrl(cleanUrl); - // URL and filters in store, URL without filters given: - // load and remove filters from store. - if (this.onceStore[absoluteUrl] && !selectorFilters) { - // eslint-disable-next-line no-console - console.warn('Warning: double import of file "' + url + '"'); - this.onceStore[absoluteUrl] = null; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } + if (!hasFilters && this.store.includes(absoluteUrl)) return true; - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - if (this.onceStore[absoluteUrl] && selectorFilters) { - var concatSelectorFilters = uniqueConcat(this.onceStore[absoluteUrl], selectorFilters); - // If stored and given selector filters are identically, do not load. - if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { - var selectorFiltersDiff = selectorFilters.filter(function (x) { - return !_this.onceStore[absoluteUrl].some(function (y) { - return JSON.stringify(x) === JSON.stringify(y); - }); - }); - this.onceStore[absoluteUrl] = concatSelectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + if (hasFilters && this.store.includes(absoluteUrl)) { + if (!this.options.disableWarnings) { + // eslint-disable-next-line no-console + console.warn('Warning: double import of file "' + absoluteUrl + '".'); } + return false; } + + if (!hasFilters) this.storeAdd(cleanUrl); + return false; } @@ -136,7 +125,7 @@ var MagicImporter = function () { }, { key: 'resolveSync', value: function resolveSync(url) { - var _this2 = this; + var _this = this; var data = null; var resolvedUrl = cleanImportUrl(url); @@ -146,15 +135,17 @@ var MagicImporter = function () { // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); - var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; + var selectorFilters = selectorImporter.parseUrl(url).selectorFilters || []; + + var hasFilters = filterNames.length || selectorFilters.length; // Try to resolve glob pattern url. var globImporter = new GlobImporter(this.options); var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); if (globFiles.length) { - return { contents: globFiles.map(function (x) { - _this2.store(x); - return fs.readFileSync(x, { encoding: 'utf8' }); + return { contents: globFiles.map(function (globUrl) { + _this.storeAdd(globUrl, hasFilters); + return fs.readFileSync(globUrl, { encoding: 'utf8' }); }).join('\n') }; } @@ -166,24 +157,19 @@ var MagicImporter = function () { data = { file: resolvedUrl }; } - var storedData = this.store(resolvedUrl, selectorFilters); - // If the file is already stored and should not be loaded, // prevent node-sass from importing the file again. - if (!storedData) { + if (this.isInStore(resolvedUrl, hasFilters)) { return { file: '', contents: '' }; } - resolvedUrl = storedData.url; - selectorFilters = storedData.selectorFilters; - // Filter. var filteredContents = void 0; // @TODO: This is ugly, maybe refactor. - if (selectorFilters) { + if (selectorFilters.length) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } if (filterNames.length) { @@ -217,10 +203,10 @@ var MagicImporter = function () { }, { key: 'resolve', value: function resolve(url) { - var _this3 = this; + var _this2 = this; return new Promise(function (promiseResolve) { - promiseResolve(_this3.resolveSync(url)); + promiseResolve(_this2.resolveSync(url)); }); } }]); diff --git a/js/lib/magic-importer.js b/js/lib/magic-importer.js index a2de550..ba461fe 100644 --- a/js/lib/magic-importer.js +++ b/js/lib/magic-importer.js @@ -1,10 +1,9 @@ -// @TODO: Add README info about filter importing. +// @TODO: Add README info about filter importing and disableWarnings option. import CssNodeExtract from 'css-node-extract'; import fs from 'fs'; import path from 'path'; import postcssSyntax from 'postcss-scss'; -import uniqueConcat from 'unique-concat'; import cleanImportUrl from 'node-sass-filter-importer/dist/lib/clean-import-url'; import extractImportFilters from 'node-sass-filter-importer/dist/lib/extract-import-filters'; @@ -41,11 +40,12 @@ export default class MagicImporter { `main.css`, `main`, ], + disableWarnings: false, }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); - /** @type {Object} */ - this.onceStore = {}; + /** @type {Array} */ + this.store = []; } /** @@ -68,54 +68,41 @@ export default class MagicImporter { } /** - * Store the given URL and selector filters - * and determine if the URL should be imported. - * @param {string} url - Import url from node-sass. - * @param {Array} selectorFilters - CSS selectors and replacement selectors. - * @return {boolean|Object} - Absolute URL and selector filters or false. + * Add an URL to the store of imported URLs. + * + * @param {String} cleanUrl + * Cleaned up import url from node-sass. */ - store(url, selectorFilters = null) { - // @TODO: Add filter logic. - const absoluteUrl = this.getAbsoluteUrl(url); - - // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { - this.onceStore[absoluteUrl] = selectorFilters; - return { url: absoluteUrl, selectorFilters }; - } + storeAdd(cleanUrl) { + const absoluteUrl = this.getAbsoluteUrl(cleanUrl); + if (!this.store.includes(absoluteUrl)) this.store.push(absoluteUrl); + } - // URL is in store without filters, filters given: load the URL. - if (this.onceStore[absoluteUrl] === null && selectorFilters) { - // eslint-disable-next-line no-console - console.warn(`Warning: double import of file "${url}"`); - return { url: absoluteUrl, selectorFilters }; - } + /** + * Check if an URL is in store, add it if is not and it has no filters. + * + * @param {String} cleanUrl + * Cleaned up import url from node-sass. + * @param {Boolean} hasFilters + * Does the URL have filters or not. + * @return {boolean} + * Returns true if the URL has no filters and is already stored. + */ + isInStore(cleanUrl, hasFilters = false) { + const absoluteUrl = this.getAbsoluteUrl(cleanUrl); - // URL and filters in store, URL without filters given: - // load and remove filters from store. - if (this.onceStore[absoluteUrl] && !selectorFilters) { - // eslint-disable-next-line no-console - console.warn(`Warning: double import of file "${url}"`); - this.onceStore[absoluteUrl] = null; - return { url: absoluteUrl, selectorFilters }; - } + if (!hasFilters && this.store.includes(absoluteUrl)) return true; - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - if (this.onceStore[absoluteUrl] && selectorFilters) { - const concatSelectorFilters = uniqueConcat( - this.onceStore[absoluteUrl], - selectorFilters - ); - // If stored and given selector filters are identically, do not load. - if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { - const selectorFiltersDiff = selectorFilters.filter(x => - !this.onceStore[absoluteUrl].some(y => JSON.stringify(x) === JSON.stringify(y)) - ); - this.onceStore[absoluteUrl] = concatSelectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; + if (hasFilters && this.store.includes(absoluteUrl)) { + if (!this.options.disableWarnings) { + // eslint-disable-next-line no-console + console.warn(`Warning: double import of file "${absoluteUrl}".`); } + return false; } + + if (!hasFilters) this.storeAdd(cleanUrl); + return false; } @@ -133,15 +120,17 @@ export default class MagicImporter { // Parse url and eventually extract selector filters. const selectorImporter = new SelectorImporter(this.options); - let selectorFilters = selectorImporter.parseUrl(url).selectorFilters; + const selectorFilters = selectorImporter.parseUrl(url).selectorFilters || []; + + const hasFilters = filterNames.length || selectorFilters.length; // Try to resolve glob pattern url. const globImporter = new GlobImporter(this.options); const globFiles = globImporter.resolveFilePathsSync(resolvedUrl); if (globFiles.length) { - return { contents: globFiles.map((x) => { - this.store(x); - return fs.readFileSync(x, { encoding: `utf8` }); + return { contents: globFiles.map((globUrl) => { + this.storeAdd(globUrl, hasFilters); + return fs.readFileSync(globUrl, { encoding: `utf8` }); }).join(`\n`) }; } @@ -153,24 +142,19 @@ export default class MagicImporter { data = { file: resolvedUrl }; } - const storedData = this.store(resolvedUrl, selectorFilters); - // If the file is already stored and should not be loaded, // prevent node-sass from importing the file again. - if (!storedData) { + if (this.isInStore(resolvedUrl, hasFilters)) { return { file: ``, contents: ``, }; } - resolvedUrl = storedData.url; - selectorFilters = storedData.selectorFilters; - // Filter. let filteredContents; // @TODO: This is ugly, maybe refactor. - if (selectorFilters) { + if (selectorFilters.length) { filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); } if (filterNames.length) { diff --git a/package.json b/package.json index 1682226..e93033a 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "node-sass": "^4.3.0", "pre-git": "^3.12.0", "rollup": "^0.41.3", - "rollup-plugin-babel": "^2.7.1" + "rollup-plugin-babel": "^2.7.1", + "sinon": "^1.17.7" }, "main": "dist/index.js", "jsnext:main": "js/index.js", diff --git a/test/lib/magic-importer.test.js b/test/lib/magic-importer.test.js index 4dbada2..cc42cb4 100644 --- a/test/lib/magic-importer.test.js +++ b/test/lib/magic-importer.test.js @@ -1,4 +1,7 @@ /* eslint-env node, mocha */ +/* eslint-disable no-console */ +/* eslint-disable no-unused-expressions */ +import sinon from 'sinon'; import { expect } from 'chai'; import MagicImporter from '../../js/lib/magic-importer'; @@ -10,162 +13,92 @@ describe(`MagicImporter`, () => { /** @test {MagicImporter#getAbsoluteUrl} */ describe(`getAbsoluteUrl()`, () => { it(`should be a function`, () => { - const magicImporterInstance = new MagicImporter(); - expect(magicImporterInstance.getAbsoluteUrl).to.be.a(`function`); + const magicImporter = new MagicImporter(); + expect(magicImporter.getAbsoluteUrl).to.be.a(`function`); }); it(`should return absolute URL`, () => { - const magicImporterInstance = new MagicImporter(); + const magicImporter = new MagicImporter(); const url = `test/files/combined.scss`; const expectedResult = `${process.cwd()}/test/files/combined.scss`; - expect(magicImporterInstance.getAbsoluteUrl(url)).to.equal(expectedResult); + expect(magicImporter.getAbsoluteUrl(url)).to.equal(expectedResult); }); }); - /** @test {MagicImporter#store} */ - describe(`store()`, () => { + /** @test {MagicImporter#storeAdd} */ + describe(`storeAdd()`, () => { it(`should be a function`, () => { - const magicImporterInstance = new MagicImporter(); - expect(magicImporterInstance.store).to.be.a(`function`); + const magicImporter = new MagicImporter(); + expect(magicImporter.storeAdd).to.be.a(`function`); }); - // URL is not in store: store and load the URL. - it(`should put the URL in the store`, () => { - const magicImporterInstance = new MagicImporter(); - const url = `/some/random/url.scss`; - const expectedOnceStoreState = {}; - expectedOnceStoreState[url] = null; - - magicImporterInstance.store(url); - expect(magicImporterInstance.onceStore).to.deep.equal(expectedOnceStoreState); + it(`should add an URL to the store`, () => { + const magicImporter = new MagicImporter(); + const url = `/some/file.scss`; + magicImporter.storeAdd(url); + expect(magicImporter.store.includes(url)).to.be.true; }); + }); - // URL is in store without filters, no filters given: do not load the URL. - it(`should return false`, () => { - const magicImporterInstance = new MagicImporter(); - const url = `/some/random/url.scss`; - const expectedResult = false; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = null; - expect(magicImporterInstance.store(url)).to.equal(expectedResult); + /** @test {MagicImporter#store} */ + describe(`isInStore()`, () => { + it(`should be a function`, () => { + const magicImporter = new MagicImporter(); + expect(magicImporter.isInStore).to.be.a(`function`); }); - // URL is in store without filters, filters given: load the URL. - it(`should return URL and selector filters in an object`, () => { - const magicImporterInstance = new MagicImporter(); - const url = `/some/random/url.scss`; - const selectorFilters = [ - [`.selector-a`], - [`.selector-b`], - ]; - const expectedResult = { - url, - selectorFilters, - }; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = null; - expect(magicImporterInstance.store(url, selectorFilters)) - .to.deep.equal(expectedResult); + it(`URL is in store, should return true`, () => { + const magicImporter = new MagicImporter(); + const url = `/some/file.scss`; + magicImporter.store = [url]; + expect(magicImporter.isInStore(url)).to.be.true; }); - // URL and filters in store, URL without filters given: - // load and remove filters from store. - it(`should remove filters from stored URL and return URL in an object`, () => { - const magicImporterInstance = new MagicImporter(); - const url = `/some/random/url.scss`; - const selectorFilters = null; - const storedSelectorFilters = [ - [`.selector-a`], - [`.selector-b`], - ]; - const expectedResult = { - url, - selectorFilters, - }; - const expectedOnceStoreState = {}; - expectedOnceStoreState[url] = null; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = storedSelectorFilters; - - expect(magicImporterInstance.store(url, selectorFilters)) - .to.deep.equal(expectedResult); - expect(magicImporterInstance.onceStore) - .to.deep.equal(expectedOnceStoreState); + it(`URL is not in store, should return false`, () => { + const magicImporter = new MagicImporter(); + const url = `/some/file.scss`; + expect(magicImporter.isInStore(url)).to.be.false; }); - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - it(`should return URL and concatenated selector filters in an object`, () => { - const magicImporterInstance = new MagicImporter(); - const url = `/some/random/url.scss`; - const selectorFilters = [ - [`.selector-a`], - [`.selector-c`], - [`.selector-d`], - ]; - const expectedSelectorFilters = [ - [`.selector-c`], - [`.selector-d`], - ]; - const storedSelectorFilters = [ - [`.selector-a`], - [`.selector-b`], - ]; - const expectedStoredSelectorFilters = [ - [`.selector-a`], - [`.selector-b`], - [`.selector-c`], - [`.selector-d`], - ]; - const expectedResult = { - url, - selectorFilters: expectedSelectorFilters, - }; - const expectedOnceStoreState = {}; - expectedOnceStoreState[url] = expectedStoredSelectorFilters; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = storedSelectorFilters; - - expect(magicImporterInstance.store(url, selectorFilters)) - .to.deep.equal(expectedResult); - expect(magicImporterInstance.onceStore) - .to.deep.equal(expectedOnceStoreState); + it(`URL is in store but URL has filters, should return false and log a warning`, () => { + const sinonInstance = sinon.sandbox.create(); + sinonInstance.stub(console, `warn`); + const magicImporter = new MagicImporter(); + const url = `/some/file.scss`; + const hasFilters = true; + magicImporter.store = [url]; + expect(magicImporter.isInStore(url, hasFilters)).to.be.false; + expect(console.warn.calledOnce).to.be.true; + expect(console.warn.calledWith(`Warning: double import of file "/some/file.scss".`)).to.be.true; + sinonInstance.restore(); }); - // URL and filters in store, URL and same filters given: do not load. - it(`should return false`, () => { - const magicImporterInstance = new MagicImporter(); - const url = `/some/random/url.scss`; - const selectorFilters = [ - [`.selector-a`], - [`.selector-b`], - ]; - const storedSelectorFilters = selectorFilters; - const expectedResult = false; - - magicImporterInstance.onceStore = {}; - magicImporterInstance.onceStore[url] = storedSelectorFilters; - expect(magicImporterInstance.store(url, selectorFilters)).to.equal(expectedResult); + it(`warnings are disabled, should log no warning`, () => { + const sinonInstance = sinon.sandbox.create(); + sinonInstance.stub(console, `warn`); + const magicImporter = new MagicImporter({ disableWarnings: true }); + const url = `/some/file.scss`; + const hasFilters = true; + magicImporter.store = [url]; + expect(magicImporter.isInStore(url, hasFilters)).to.be.false; + expect(console.warn.calledOnce).to.be.false; + sinonInstance.restore(); }); }); /** @test {MagicImporter#resolveSync} */ describe(`resolveSync()`, () => { it(`should be a function`, () => { - const magicImporterInstance = new MagicImporter(); - expect(magicImporterInstance.resolveSync).to.be.a(`function`); + const magicImporter = new MagicImporter(); + expect(magicImporter.resolveSync).to.be.a(`function`); }); }); /** @test {MagicImporter#resolve} */ describe(`resolve()`, () => { it(`should be a function`, () => { - const magicImporterInstance = new MagicImporter(); - expect(magicImporterInstance.resolve).to.be.a(`function`); + const magicImporter = new MagicImporter(); + expect(magicImporter.resolve).to.be.a(`function`); }); }); }); diff --git a/yarn.lock b/yarn.lock index 7caa6fa..903be1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -665,12 +665,6 @@ caseless@~0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" -chai-as-promised@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-6.0.0.tgz#1a02a433a6f24dafac63b9c96fa1684db1aa8da6" - dependencies: - check-error "^1.0.2" - chai@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247" @@ -699,10 +693,6 @@ chdir-promise@0.2.1: q "1.1.2" spots "0.3.0" -check-error@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" - check-more-types@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-1.1.0.tgz#3d0e36cbfbe907b3e5ec0a14f6b256086452c216" @@ -1045,14 +1035,14 @@ dom-serializer@0, dom-serializer@~0.1.0: domelementtype "~1.1.1" entities "~1.1.1" -domelementtype@1, domelementtype@~1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" - -domelementtype@^1.3.0: +domelementtype@1, domelementtype@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" +domelementtype@~1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" + domhandler@2.3, domhandler@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.3.0.tgz#2de59a0822d5027fabff6f032c2b25a2a8abe738" @@ -1404,6 +1394,12 @@ form-data@~2.0.0: combined-stream "^1.0.5" mime-types "^2.1.11" +formatio@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" + dependencies: + samsam "~1.1" + foundation-sites@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/foundation-sites/-/foundation-sites-6.3.0.tgz#19b2d6e5edced8418a4a7b4a1d65287ee1c8d512" @@ -1567,11 +1563,7 @@ globals@^8.3.0: version "8.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-8.18.0.tgz#93d4a62bdcac38cfafafc47d6b034768cb0ffcb4" -globals@^9.0.0: - version "9.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.12.0.tgz#992ce90828c3a55fa8f16fada177adb64664cf9d" - -globals@^9.14.0: +globals@^9.0.0, globals@^9.14.0: version "9.14.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034" @@ -1732,6 +1724,10 @@ inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" +inherits@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + inquirer-confirm@0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/inquirer-confirm/-/inquirer-confirm-0.2.2.tgz#6f406d037bf9d9e455ef0f953929f357fe9a8848" @@ -2160,6 +2156,10 @@ lodash@~4.9.0: version "4.9.0" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.9.0.tgz#4c20d742f03ce85dc700e0dd7ab9bcab85e6fc14" +lolex@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" + loose-envify@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.0.tgz#6b26248c42f6d4fa4b0d8542f78edfcde35642a8" @@ -2867,6 +2867,10 @@ rx@^2.4.3: version "2.5.3" resolved "https://registry.yarnpkg.com/rx/-/rx-2.5.3.tgz#21adc7d80f02002af50dae97fd9dbf248755f566" +samsam@1.1.2, samsam@~1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" + sass-graph@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/sass-graph/-/sass-graph-2.1.2.tgz#965104be23e8103cb7e5f710df65935b317da57b" @@ -2924,6 +2928,15 @@ simple-commit-message@2.2.1: semver "5.1.0" word-wrap "1.1.0" +sinon@^1.17.7: + version "1.17.7" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf" + dependencies: + formatio "1.1.1" + lolex "1.3.2" + samsam "1.1.2" + util ">=0.10.3 <1" + slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" @@ -3154,6 +3167,12 @@ util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" +"util@>=0.10.3 <1": + version "0.10.3" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + dependencies: + inherits "2.0.1" + validate-commit-msg@2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/validate-commit-msg/-/validate-commit-msg-2.5.0.tgz#a7d0a68aa3917171b560664689a2ac59c25908b6" From 38c435b4a0c16dcff25cd9b1c34724e7048bc562 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:08:16 +0100 Subject: [PATCH 15/23] Optimize the main index file. Add default options as separate module. Fix a problem with resolving absolute paths. --- dist/cli.js | 63 +++++++++++++++++++++++-------------- dist/index.js | 63 +++++++++++++++++++++++-------------- dist/lib/magic-importer.js | 26 +++++++++------ js/index.js | 41 +++++++++++++++--------- js/lib/default-options.js | 27 ++++++++++++++++ js/lib/magic-importer.js | 28 ++++------------- test/lib/default-options.js | 9 ++++++ 7 files changed, 165 insertions(+), 92 deletions(-) create mode 100644 js/lib/default-options.js create mode 100644 test/lib/default-options.js diff --git a/dist/cli.js b/dist/cli.js index 6375270..d65e07c 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -3,6 +3,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var path = _interopDefault(require('path')); +var uniqueConcat = _interopDefault(require('unique-concat')); var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var postcssSyntax = _interopDefault(require('postcss-scss')); @@ -13,6 +14,19 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter')); +/** + * Default options. + * + * @type {Object} + */ +var defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: [".scss", ".sass"], + packageKeys: ["sass", "scss", "style", "css", "main.sass", "main.scss", "main.style", "main.css", "main"], + disableWarnings: false +}; + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -33,13 +47,6 @@ var MagicImporter = function () { _classCallCheck(this, MagicImporter); - var defaultOptions = { - cwd: process.cwd(), - includePaths: [process.cwd()], - extensions: ['.scss', '.sass'], - packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'], - disableWarnings: false - }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); /** @type {Array} */ @@ -60,9 +67,11 @@ var MagicImporter = function () { if (!path.isAbsolute(url)) { this.options.includePaths.some(function (includePath) { try { - absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); + absoluteUrl = path.normalize(path.resolve(includePath, absoluteUrl)); return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} // eslint-disable-line no-empty + } catch (e) { + absoluteUrl = url; + } return false; }); } @@ -215,27 +224,35 @@ var MagicImporter = function () { }(); /** - * Magic importer for node-sass - * @param {Object} options - Configuration options. + * Magic importer for node-sass. + * + * @param {Object} customOptions + * Custom configuration options. + * @return {Function} + * node-sass custom importer function. */ var importer = (function () { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var customOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var options = Object.assign({}, defaultOptions, customOptions); + var magicImporter = new MagicImporter(options); - var magicImporter = new MagicImporter(); /** - * @param {string} url - The path in import as-is, which LibSass encountered. - * @param {string} prev - The previously resolved path. + * @param {string} url + * The path in import as-is, which LibSass encountered. + * @param {string} prev + * The previously resolved path. + * @return {Object|null} + * node-sass custom importer data object or null. */ return function importer(url, prev) { - // Create an array of include paths to search for files. - var includePaths = []; - if (path.isAbsolute(prev)) { - includePaths.push(path.dirname(prev)); - } - magicImporter.options.includePaths = includePaths.concat(this.options.includePaths.split(path.delimiter)); + var nodeSassIncludePaths = this.options.includePaths.split(path.delimiter); + + if (path.isAbsolute(prev)) nodeSassIncludePaths.push(path.dirname(prev)); + magicImporter.options.includePaths = uniqueConcat(options.includePaths, nodeSassIncludePaths).filter(function (item) { + return item.length; + }); - // Merge default with custom options. - Object.assign(magicImporter.options, options); return magicImporter.resolveSync(url); }; }); diff --git a/dist/index.js b/dist/index.js index fcbddb6..d2f739b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3,6 +3,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var path = _interopDefault(require('path')); +var uniqueConcat = _interopDefault(require('unique-concat')); var CssNodeExtract = _interopDefault(require('css-node-extract')); var fs = _interopDefault(require('fs')); var postcssSyntax = _interopDefault(require('postcss-scss')); @@ -13,6 +14,19 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter')); +/** + * Default options. + * + * @type {Object} + */ +var defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: [".scss", ".sass"], + packageKeys: ["sass", "scss", "style", "css", "main.sass", "main.scss", "main.style", "main.css", "main"], + disableWarnings: false +}; + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -33,13 +47,6 @@ var MagicImporter = function () { _classCallCheck(this, MagicImporter); - var defaultOptions = { - cwd: process.cwd(), - includePaths: [process.cwd()], - extensions: ['.scss', '.sass'], - packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'], - disableWarnings: false - }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); /** @type {Array} */ @@ -60,9 +67,11 @@ var MagicImporter = function () { if (!path.isAbsolute(url)) { this.options.includePaths.some(function (includePath) { try { - absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); + absoluteUrl = path.normalize(path.resolve(includePath, absoluteUrl)); return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} // eslint-disable-line no-empty + } catch (e) { + absoluteUrl = url; + } return false; }); } @@ -215,27 +224,35 @@ var MagicImporter = function () { }(); /** - * Magic importer for node-sass - * @param {Object} options - Configuration options. + * Magic importer for node-sass. + * + * @param {Object} customOptions + * Custom configuration options. + * @return {Function} + * node-sass custom importer function. */ var index = (function () { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var customOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var options = Object.assign({}, defaultOptions, customOptions); + var magicImporter = new MagicImporter(options); - var magicImporter = new MagicImporter(); /** - * @param {string} url - The path in import as-is, which LibSass encountered. - * @param {string} prev - The previously resolved path. + * @param {string} url + * The path in import as-is, which LibSass encountered. + * @param {string} prev + * The previously resolved path. + * @return {Object|null} + * node-sass custom importer data object or null. */ return function importer(url, prev) { - // Create an array of include paths to search for files. - var includePaths = []; - if (path.isAbsolute(prev)) { - includePaths.push(path.dirname(prev)); - } - magicImporter.options.includePaths = includePaths.concat(this.options.includePaths.split(path.delimiter)); + var nodeSassIncludePaths = this.options.includePaths.split(path.delimiter); + + if (path.isAbsolute(prev)) nodeSassIncludePaths.push(path.dirname(prev)); + magicImporter.options.includePaths = uniqueConcat(options.includePaths, nodeSassIncludePaths).filter(function (item) { + return item.length; + }); - // Merge default with custom options. - Object.assign(magicImporter.options, options); return magicImporter.resolveSync(url); }; }); diff --git a/dist/lib/magic-importer.js b/dist/lib/magic-importer.js index eb5475f..1c16c6e 100644 --- a/dist/lib/magic-importer.js +++ b/dist/lib/magic-importer.js @@ -13,6 +13,19 @@ var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImp var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter')); var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter')); +/** + * Default options. + * + * @type {Object} + */ +var defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: [".scss", ".sass"], + packageKeys: ["sass", "scss", "style", "css", "main.sass", "main.scss", "main.style", "main.css", "main"], + disableWarnings: false +}; + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -33,13 +46,6 @@ var MagicImporter = function () { _classCallCheck(this, MagicImporter); - var defaultOptions = { - cwd: process.cwd(), - includePaths: [process.cwd()], - extensions: ['.scss', '.sass'], - packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'], - disableWarnings: false - }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); /** @type {Array} */ @@ -60,9 +66,11 @@ var MagicImporter = function () { if (!path.isAbsolute(url)) { this.options.includePaths.some(function (includePath) { try { - absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); + absoluteUrl = path.normalize(path.resolve(includePath, absoluteUrl)); return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} // eslint-disable-line no-empty + } catch (e) { + absoluteUrl = url; + } return false; }); } diff --git a/js/index.js b/js/index.js index 1cc8229..5af66e9 100644 --- a/js/index.js +++ b/js/index.js @@ -1,27 +1,38 @@ import path from 'path'; +import uniqueConcat from 'unique-concat'; + +import defaultOptions from './lib/default-options'; import MagicImporter from './lib/magic-importer'; /** - * Magic importer for node-sass - * @param {Object} options - Configuration options. + * Magic importer for node-sass. + * + * @param {Object} customOptions + * Custom configuration options. + * @return {Function} + * node-sass custom importer function. */ -export default (options = {}) => { - const magicImporter = new MagicImporter(); +export default (customOptions = {}) => { + const options = Object.assign({}, defaultOptions, customOptions); + const magicImporter = new MagicImporter(options); + /** - * @param {string} url - The path in import as-is, which LibSass encountered. - * @param {string} prev - The previously resolved path. + * @param {string} url + * The path in import as-is, which LibSass encountered. + * @param {string} prev + * The previously resolved path. + * @return {Object|null} + * node-sass custom importer data object or null. */ return function importer(url, prev) { - // Create an array of include paths to search for files. - const includePaths = []; - if (path.isAbsolute(prev)) { - includePaths.push(path.dirname(prev)); - } - magicImporter.options.includePaths = includePaths - .concat(this.options.includePaths.split(path.delimiter)); + const nodeSassIncludePaths = this.options.includePaths.split(path.delimiter); + + if (path.isAbsolute(prev)) nodeSassIncludePaths.push(path.dirname(prev)); + magicImporter.options.includePaths = uniqueConcat( + options.includePaths, + nodeSassIncludePaths + ).filter(item => item.length); - // Merge default with custom options. - Object.assign(magicImporter.options, options); return magicImporter.resolveSync(url); }; }; diff --git a/js/lib/default-options.js b/js/lib/default-options.js new file mode 100644 index 0000000..0f9b527 --- /dev/null +++ b/js/lib/default-options.js @@ -0,0 +1,27 @@ +/** + * Default options. + * + * @type {Object} + */ +const defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: [ + `.scss`, + `.sass`, + ], + packageKeys: [ + `sass`, + `scss`, + `style`, + `css`, + `main.sass`, + `main.scss`, + `main.style`, + `main.css`, + `main`, + ], + disableWarnings: false, +}; + +export default defaultOptions; diff --git a/js/lib/magic-importer.js b/js/lib/magic-importer.js index ba461fe..cb90deb 100644 --- a/js/lib/magic-importer.js +++ b/js/lib/magic-importer.js @@ -13,6 +13,8 @@ import GlobImporter from 'node-sass-glob-importer/dist/GlobImporter'; import PackageImporter from 'node-sass-package-importer/dist/PackageImporter'; import SelectorImporter from 'node-sass-selector-importer/dist/SelectorImporter'; +import defaultOptions from './default-options'; + /** * Selector specific imports, module importing, * globbing support, import files only once. @@ -22,26 +24,6 @@ export default class MagicImporter { * @param {Object} options - Configuration options. */ constructor(options = {}) { - const defaultOptions = { - cwd: process.cwd(), - includePaths: [process.cwd()], - extensions: [ - `.scss`, - `.sass`, - ], - packageKeys: [ - `sass`, - `scss`, - `style`, - `css`, - `main.sass`, - `main.scss`, - `main.style`, - `main.css`, - `main`, - ], - disableWarnings: false, - }; /** @type {Object} */ this.options = Object.assign({}, defaultOptions, options); /** @type {Array} */ @@ -58,9 +40,11 @@ export default class MagicImporter { if (!path.isAbsolute(url)) { this.options.includePaths.some((includePath) => { try { - absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); + absoluteUrl = path.normalize(path.resolve(includePath, absoluteUrl)); return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} // eslint-disable-line no-empty + } catch (e) { + absoluteUrl = url; + } return false; }); } diff --git a/test/lib/default-options.js b/test/lib/default-options.js new file mode 100644 index 0000000..3d17133 --- /dev/null +++ b/test/lib/default-options.js @@ -0,0 +1,9 @@ +/* eslint-env node, mocha */ +import { expect } from 'chai'; + +import defaultOptions from '../../js/lib/default-options'; + +/** @test {defaultOptions} */ +describe(`defaultOptions`, () => { + it(`should be an object`, () => expect(defaultOptions).to.be.an(`Object`)); +}); From 033fe16a8f034bc5d3a162dad734398447eca16a Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:08:51 +0100 Subject: [PATCH 16/23] Update the filter importer module. --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e93033a..a3e9ec7 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "dependencies": { "css-node-extract": "^0.2.1", - "node-sass-filter-importer": "^1.0.0", + "node-sass-filter-importer": "^1.0.1", "node-sass-glob-importer": "^3.0.2", "node-sass-package-importer": "^3.0.1", "node-sass-selector-importer": "^4.2.0", diff --git a/yarn.lock b/yarn.lock index 903be1d..822fc05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2308,9 +2308,9 @@ node-gyp@^3.3.1: tar "^2.0.0" which "1" -node-sass-filter-importer@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/node-sass-filter-importer/-/node-sass-filter-importer-1.0.0.tgz#a41846bf614dd1a840ad5d3b6f261dceb874da6e" +node-sass-filter-importer@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/node-sass-filter-importer/-/node-sass-filter-importer-1.0.1.tgz#875cb640681ab597fc9e0cb515cacb4f282a22ad" dependencies: css-node-extract "^0.1.0" postcss-scss "^0.4.0" From c5c2e68d468eff777c8da0bbadbad48eeb8a792f Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:11:37 +0100 Subject: [PATCH 17/23] Reformat doc block comments. --- dist/cli.js | 26 +++++++++++++++++--------- dist/index.js | 26 +++++++++++++++++--------- dist/lib/magic-importer.js | 26 +++++++++++++++++--------- js/lib/magic-importer.js | 26 +++++++++++++++++--------- 4 files changed, 68 insertions(+), 36 deletions(-) diff --git a/dist/cli.js b/dist/cli.js index d65e07c..2068a4f 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -34,8 +34,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons // @TODO: Add README info about filter importing and disableWarnings option. /** - * Selector specific imports, module importing, - * globbing support, import files only once. + * Selector specific imports, filter imports, module importing, + * globbing support and import files only once. */ var MagicImporter = function () { @@ -55,8 +55,11 @@ var MagicImporter = function () { /** * Find the absolute URL for a given relative URL. - * @param {string} url - Import url from node-sass. - * @return {string} Absolute import url. + * + * @param {String} url + * Import url from node-sass. + * @return {String} + * Absolute import url. */ @@ -127,8 +130,11 @@ var MagicImporter = function () { /** * Synchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {string} Importer object or null. + * + * @param {String} url + * Import url from node-sass. + * @return {String} + * Importer object or null. */ }, { @@ -145,7 +151,6 @@ var MagicImporter = function () { // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); var selectorFilters = selectorImporter.parseUrl(url).selectorFilters || []; - var hasFilters = filterNames.length || selectorFilters.length; // Try to resolve glob pattern url. @@ -205,8 +210,11 @@ var MagicImporter = function () { /** * Asynchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {Promise} Promise for importer object or null. + * + * @param {string} url + * Import url from node-sass. + * @return {Promise} + * Promise for importer object or null. */ }, { diff --git a/dist/index.js b/dist/index.js index d2f739b..1e84018 100644 --- a/dist/index.js +++ b/dist/index.js @@ -34,8 +34,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons // @TODO: Add README info about filter importing and disableWarnings option. /** - * Selector specific imports, module importing, - * globbing support, import files only once. + * Selector specific imports, filter imports, module importing, + * globbing support and import files only once. */ var MagicImporter = function () { @@ -55,8 +55,11 @@ var MagicImporter = function () { /** * Find the absolute URL for a given relative URL. - * @param {string} url - Import url from node-sass. - * @return {string} Absolute import url. + * + * @param {String} url + * Import url from node-sass. + * @return {String} + * Absolute import url. */ @@ -127,8 +130,11 @@ var MagicImporter = function () { /** * Synchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {string} Importer object or null. + * + * @param {String} url + * Import url from node-sass. + * @return {String} + * Importer object or null. */ }, { @@ -145,7 +151,6 @@ var MagicImporter = function () { // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); var selectorFilters = selectorImporter.parseUrl(url).selectorFilters || []; - var hasFilters = filterNames.length || selectorFilters.length; // Try to resolve glob pattern url. @@ -205,8 +210,11 @@ var MagicImporter = function () { /** * Asynchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {Promise} Promise for importer object or null. + * + * @param {string} url + * Import url from node-sass. + * @return {Promise} + * Promise for importer object or null. */ }, { diff --git a/dist/lib/magic-importer.js b/dist/lib/magic-importer.js index 1c16c6e..b26ff63 100644 --- a/dist/lib/magic-importer.js +++ b/dist/lib/magic-importer.js @@ -33,8 +33,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons // @TODO: Add README info about filter importing and disableWarnings option. /** - * Selector specific imports, module importing, - * globbing support, import files only once. + * Selector specific imports, filter imports, module importing, + * globbing support and import files only once. */ var MagicImporter = function () { @@ -54,8 +54,11 @@ var MagicImporter = function () { /** * Find the absolute URL for a given relative URL. - * @param {string} url - Import url from node-sass. - * @return {string} Absolute import url. + * + * @param {String} url + * Import url from node-sass. + * @return {String} + * Absolute import url. */ @@ -126,8 +129,11 @@ var MagicImporter = function () { /** * Synchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {string} Importer object or null. + * + * @param {String} url + * Import url from node-sass. + * @return {String} + * Importer object or null. */ }, { @@ -144,7 +150,6 @@ var MagicImporter = function () { // Parse url and eventually extract selector filters. var selectorImporter = new SelectorImporter(this.options); var selectorFilters = selectorImporter.parseUrl(url).selectorFilters || []; - var hasFilters = filterNames.length || selectorFilters.length; // Try to resolve glob pattern url. @@ -204,8 +209,11 @@ var MagicImporter = function () { /** * Asynchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {Promise} Promise for importer object or null. + * + * @param {string} url + * Import url from node-sass. + * @return {Promise} + * Promise for importer object or null. */ }, { diff --git a/js/lib/magic-importer.js b/js/lib/magic-importer.js index cb90deb..0bd02e2 100644 --- a/js/lib/magic-importer.js +++ b/js/lib/magic-importer.js @@ -16,8 +16,8 @@ import SelectorImporter from 'node-sass-selector-importer/dist/SelectorImporter' import defaultOptions from './default-options'; /** - * Selector specific imports, module importing, - * globbing support, import files only once. + * Selector specific imports, filter imports, module importing, + * globbing support and import files only once. */ export default class MagicImporter { /** @@ -32,8 +32,11 @@ export default class MagicImporter { /** * Find the absolute URL for a given relative URL. - * @param {string} url - Import url from node-sass. - * @return {string} Absolute import url. + * + * @param {String} url + * Import url from node-sass. + * @return {String} + * Absolute import url. */ getAbsoluteUrl(url) { let absoluteUrl = url; @@ -92,8 +95,11 @@ export default class MagicImporter { /** * Synchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {string} Importer object or null. + * + * @param {String} url + * Import url from node-sass. + * @return {String} + * Importer object or null. */ resolveSync(url) { let data = null; @@ -105,7 +111,6 @@ export default class MagicImporter { // Parse url and eventually extract selector filters. const selectorImporter = new SelectorImporter(this.options); const selectorFilters = selectorImporter.parseUrl(url).selectorFilters || []; - const hasFilters = filterNames.length || selectorFilters.length; // Try to resolve glob pattern url. @@ -165,8 +170,11 @@ export default class MagicImporter { /** * Asynchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {Promise} Promise for importer object or null. + * + * @param {string} url + * Import url from node-sass. + * @return {Promise} + * Promise for importer object or null. */ resolve(url) { return new Promise((promiseResolve) => { From 3a8fe24d45b1931708e95775271946bb17e88b17 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:14:03 +0100 Subject: [PATCH 18/23] Remove old dist files. Delete dist directory before rebuilding. Add default options dist file. --- dist/MagicImporter.js | 232 ------------------------------------ dist/lib/default-options.js | 16 +++ package.json | 2 +- 3 files changed, 17 insertions(+), 233 deletions(-) delete mode 100644 dist/MagicImporter.js create mode 100644 dist/lib/default-options.js diff --git a/dist/MagicImporter.js b/dist/MagicImporter.js deleted file mode 100644 index e609010..0000000 --- a/dist/MagicImporter.js +++ /dev/null @@ -1,232 +0,0 @@ -'use strict'; - -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - -var CssNodeExtract = _interopDefault(require('css-node-extract')); -var fs = _interopDefault(require('fs')); -var path = _interopDefault(require('path')); -var postcssSyntax = _interopDefault(require('postcss-scss')); -var uniqueConcat = _interopDefault(require('unique-concat')); -var extractImportFilters = _interopDefault(require('node-sass-filter-importer/dist/lib/extract-import-filters')); -var FilterImporter = _interopDefault(require('node-sass-filter-importer/dist/lib/filter-importer')); -var GlobImporter = _interopDefault(require('node-sass-glob-importer/dist/GlobImporter')); -var PackageImporter = _interopDefault(require('node-sass-package-importer/dist/PackageImporter')); -var SelectorImporter = _interopDefault(require('node-sass-selector-importer/dist/SelectorImporter')); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// @TODO: Add README info about filter importing. - -/** - * Selector specific imports, module importing, - * globbing support, import files only once. - */ - -var MagicImporter = function () { - /** - * @param {Object} options - Configuration options. - */ - function MagicImporter() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, MagicImporter); - - var defaultOptions = { - cwd: process.cwd(), - includePaths: [process.cwd()], - extensions: ['.scss', '.sass'], - packageKeys: ['sass', 'scss', 'style', 'css', 'main.sass', 'main.scss', 'main.style', 'main.css', 'main'] - }; - /** @type {Object} */ - this.options = Object.assign({}, defaultOptions, options); - /** @type {Object} */ - this.onceStore = {}; - } - - /** - * Find the absolute URL for a given relative URL. - * @param {string} url - Import url from node-sass. - * @return {string} Absolute import url. - */ - - - _createClass(MagicImporter, [{ - key: 'getAbsoluteUrl', - value: function getAbsoluteUrl(url) { - var absoluteUrl = url; - if (!path.isAbsolute(url)) { - this.options.includePaths.some(function (includePath) { - try { - absoluteUrl = path.normalize(path.join(includePath, absoluteUrl)); - return fs.statSync(absoluteUrl).isFile(); - } catch (e) {} // eslint-disable-line no-empty - return false; - }); - } - return absoluteUrl; - } - - /** - * Store the given URL and selector filters - * and determine if the URL should be imported. - * @param {string} url - Import url from node-sass. - * @param {Array} selectorFilters - CSS selectors and replacement selectors. - * @return {boolean|Object} - Absolute URL and selector filters or false. - */ - - }, { - key: 'store', - value: function store(url) { - var _this = this; - - var selectorFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - - // @TODO: Add filter logic. - var absoluteUrl = this.getAbsoluteUrl(url); - - // URL is not in store: store and load the URL. - if (this.onceStore[absoluteUrl] === undefined) { - this.onceStore[absoluteUrl] = selectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } - - // URL is in store without filters, filters given: load the URL. - if (this.onceStore[absoluteUrl] === null && selectorFilters) { - // eslint-disable-next-line no-console - console.warn('Warning: double import of file "' + url + '"'); - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } - - // URL and filters in store, URL without filters given: - // load and remove filters from store. - if (this.onceStore[absoluteUrl] && !selectorFilters) { - // eslint-disable-next-line no-console - console.warn('Warning: double import of file "' + url + '"'); - this.onceStore[absoluteUrl] = null; - return { url: absoluteUrl, selectorFilters: selectorFilters }; - } - - // URL and filters in store, URL with same and other filters given: - // only load other filters that not already are stored. - if (this.onceStore[absoluteUrl] && selectorFilters) { - var concatSelectorFilters = uniqueConcat(this.onceStore[absoluteUrl], selectorFilters); - // If stored and given selector filters are identically, do not load. - if (JSON.stringify(concatSelectorFilters) !== JSON.stringify(this.onceStore[absoluteUrl])) { - var selectorFiltersDiff = selectorFilters.filter(function (x) { - return !_this.onceStore[absoluteUrl].some(function (y) { - return JSON.stringify(x) === JSON.stringify(y); - }); - }); - this.onceStore[absoluteUrl] = concatSelectorFilters; - return { url: absoluteUrl, selectorFilters: selectorFiltersDiff }; - } - } - return false; - } - - /** - * Synchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {string} Importer object or null. - */ - - }, { - key: 'resolveSync', - value: function resolveSync(url) { - var _this2 = this; - - var data = null; - // @TODO: Ugly. - var resolvedUrl = url.split('from')[1] || url; - resolvedUrl = resolvedUrl.trim(); - - // Parse url and eventually extract filters. - var filterNames = extractImportFilters(url); - - // Parse url and eventually extract selector filters. - var selectorImporter = new SelectorImporter(this.options); - var selectorFilters = selectorImporter.parseUrl(url).selectorFilters; - - // Try to resolve glob pattern url. - var globImporter = new GlobImporter(this.options); - var globFiles = globImporter.resolveFilePathsSync(resolvedUrl); - if (globFiles.length) { - return { contents: globFiles.map(function (x) { - _this2.store(x); - return fs.readFileSync(x, { encoding: 'utf8' }); - }).join('\n') }; - } - - // Try to resolve a module url. - var packageImporter = new PackageImporter(this.options); - var packageImportData = packageImporter.resolveSync(resolvedUrl); - if (packageImportData) { - resolvedUrl = packageImportData.file; - data = { file: resolvedUrl }; - } - - var storedData = this.store(resolvedUrl, selectorFilters); - - // If the file is already stored and should not be loaded, - // prevent node-sass from importing the file again. - if (!storedData) { - return { - file: '', - contents: '' - }; - } - - resolvedUrl = storedData.url; - selectorFilters = storedData.selectorFilters; - - // Filter. - var filteredContents = void 0; - // @TODO: This is ugly, maybe refactor. - if (selectorFilters) { - filteredContents = selectorImporter.extractSelectors(resolvedUrl, selectorFilters); - } - if (filterNames.length) { - if (filteredContents) { - filteredContents = CssNodeExtract.processSync({ - css: filteredContents, - filterNames: filterNames, - postcssSyntax: postcssSyntax - }); - } else { - var filterImporter = new FilterImporter(this.options); - filteredContents = filterImporter.extractFilters(resolvedUrl, filterNames); - } - } - if (filteredContents) { - data = { - file: resolvedUrl, - contents: filteredContents - }; - } - - return data; - } - - /** - * Asynchronously resolve the path to a node-sass import url. - * @param {string} url - Import url from node-sass. - * @return {Promise} Promise for importer object or null. - */ - - }, { - key: 'resolve', - value: function resolve(url) { - var _this3 = this; - - return new Promise(function (promiseResolve) { - promiseResolve(_this3.resolveSync(url)); - }); - } - }]); - - return MagicImporter; -}(); - -module.exports = MagicImporter; diff --git a/dist/lib/default-options.js b/dist/lib/default-options.js new file mode 100644 index 0000000..e23db00 --- /dev/null +++ b/dist/lib/default-options.js @@ -0,0 +1,16 @@ +'use strict'; + +/** + * Default options. + * + * @type {Object} + */ +var defaultOptions = { + cwd: process.cwd(), + includePaths: [process.cwd()], + extensions: [".scss", ".sass"], + packageKeys: ["sass", "scss", "style", "css", "main.sass", "main.scss", "main.style", "main.css", "main"], + disableWarnings: false +}; + +module.exports = defaultOptions; diff --git a/package.json b/package.json index a3e9ec7..3ef97d7 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "main": "dist/index.js", "jsnext:main": "js/index.js", "scripts": { - "scripts:bundle": "rollup --config --format cjs --output dist/index.js js/index.js && rollup --config --format cjs --output dist/cli.js js/cli.js && rollup --config --format cjs --output dist/lib/magic-importer.js js/lib/magic-importer.js", + "scripts:bundle": "rm -R dist && rollup --config --format cjs --output dist/cli.js js/cli.js && rollup --config --format cjs --output dist/index.js js/index.js && rollup --config --format cjs --output dist/lib/default-options.js js/lib/default-options.js && rollup --config --format cjs --output dist/lib/magic-importer.js js/lib/magic-importer.js", "scripts:lint": "eslint js/* test/*", "scripts:lint-no-error": "eslint js/* test/* || exit 0", "scripts:doc": "esdoc -c .esdocrc", From 875b5cb031e8e765c8fbc3034e6e3890648ccb94 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:22:46 +0100 Subject: [PATCH 19/23] Add infos about node filtering to the README. --- README.md | 36 ++++++++++++++++++++++++++++++++++-- dist/cli.js | 3 +-- dist/index.js | 3 +-- dist/lib/default-options.js | 1 + dist/lib/magic-importer.js | 3 +-- js/lib/default-options.js | 1 + js/lib/magic-importer.js | 2 -- 7 files changed, 39 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9931482..62a0130 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,14 @@ Custom node-sass importer for selector specific imports, module importing, globb This importer enables several comfort functions for importing SASS files more easily. - [Selector filtering](#selector-filtering): import only specific selectors from a file. (Uses the [node-sass-selector-importer](https://github.com/maoberlehner/node-sass-selector-importer) module.) +- [Node filtering](#node-filtering): import only specific nodes from a file. + (Uses the [node-sass-filter-importer](https://github.com/maoberlehner/node-sass-filter-importer) module.) - [Module importing](#module-importing): import modules from `node_modules` without specifying the full path. (Uses the [node-sass-package-importer](https://github.com/maoberlehner/node-sass-package-importer) module.) - [Globbing](#globbing): use globbing (e.g. `@import: 'scss/**/*.scss'`) to import multiple files at once. (Uses the [node-sass-glob-importer](https://github.com/maoberlehner/node-sass-glob-importer) module.) -By default every file is only imported once even if you `@import` the same file multiple times in your code. +By default every file is only imported once even if you `@import` the same file multiple times in your code (except if you are using filters). ### Selector filtering With selector filtering, it is possible to import only certain CSS selectors form a file. This is especially useful if you want to import only a few CSS classes from a huge library or framework. @@ -97,6 +99,34 @@ Bootstrap is a mighty and robust framework but most of the time you use only cer **You may notice that source map support is limited for styles which are imported with selector filtering. If you have an idea how to fix this, please feel free to create a new issue or pull request.** +### Node filtering +Filter certain elements from SCSS code. + +```scss +// Example: +@import '[variables, mixins] from style.scss'; +``` +```scss +// style.scss: +$variable1: 'value'; +$variable2: 'value'; +.selector { } +@mixin mixin() { } + +// Result: +$variable1: 'value'; +$variable2: 'value'; +@mixin mixin() { } +``` + +#### Filters +- **at-rules**: `@media`, `@supports`, `@mixin`,... +- **functions**: `@function` +- **mixins**: `@mixin` +- **rules**: `.class-selector`, `#id-selector`,... +- **silent**: Extract only nodes that do not compile to CSS code (mixins, placeholder selectors, variables,...) +- **variables**: `$variable` + ### Module importing In modern day web development, modules and packages are everywhere. There is no way around [npm](https://www.npmjs.com/) if you are a JavaScript developer. More and more CSS and SASS projects move to npm but it can be annoying to find a convenient way of including them into your project. Module importing makes this a little easier. @@ -169,7 +199,9 @@ var options = { 'main' ], // You can set the special character for indicating a module resolution. - prefix: '~' + prefix: '~', + // Disable console warnings. + disableWarnings: false }; sass.render({ diff --git a/dist/cli.js b/dist/cli.js index 2068a4f..e9704bd 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -24,6 +24,7 @@ var defaultOptions = { includePaths: [process.cwd()], extensions: [".scss", ".sass"], packageKeys: ["sass", "scss", "style", "css", "main.sass", "main.scss", "main.style", "main.css", "main"], + prefix: "~", disableWarnings: false }; @@ -31,8 +32,6 @@ var _createClass = function () { function defineProperties(target, props) { for function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -// @TODO: Add README info about filter importing and disableWarnings option. - /** * Selector specific imports, filter imports, module importing, * globbing support and import files only once. diff --git a/dist/index.js b/dist/index.js index 1e84018..6d43a9f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -24,6 +24,7 @@ var defaultOptions = { includePaths: [process.cwd()], extensions: [".scss", ".sass"], packageKeys: ["sass", "scss", "style", "css", "main.sass", "main.scss", "main.style", "main.css", "main"], + prefix: "~", disableWarnings: false }; @@ -31,8 +32,6 @@ var _createClass = function () { function defineProperties(target, props) { for function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -// @TODO: Add README info about filter importing and disableWarnings option. - /** * Selector specific imports, filter imports, module importing, * globbing support and import files only once. diff --git a/dist/lib/default-options.js b/dist/lib/default-options.js index e23db00..01dd8cb 100644 --- a/dist/lib/default-options.js +++ b/dist/lib/default-options.js @@ -10,6 +10,7 @@ var defaultOptions = { includePaths: [process.cwd()], extensions: [".scss", ".sass"], packageKeys: ["sass", "scss", "style", "css", "main.sass", "main.scss", "main.style", "main.css", "main"], + prefix: "~", disableWarnings: false }; diff --git a/dist/lib/magic-importer.js b/dist/lib/magic-importer.js index b26ff63..5ab0e43 100644 --- a/dist/lib/magic-importer.js +++ b/dist/lib/magic-importer.js @@ -23,6 +23,7 @@ var defaultOptions = { includePaths: [process.cwd()], extensions: [".scss", ".sass"], packageKeys: ["sass", "scss", "style", "css", "main.sass", "main.scss", "main.style", "main.css", "main"], + prefix: "~", disableWarnings: false }; @@ -30,8 +31,6 @@ var _createClass = function () { function defineProperties(target, props) { for function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -// @TODO: Add README info about filter importing and disableWarnings option. - /** * Selector specific imports, filter imports, module importing, * globbing support and import files only once. diff --git a/js/lib/default-options.js b/js/lib/default-options.js index 0f9b527..d187cdf 100644 --- a/js/lib/default-options.js +++ b/js/lib/default-options.js @@ -21,6 +21,7 @@ const defaultOptions = { `main.css`, `main`, ], + prefix: `~`, disableWarnings: false, }; diff --git a/js/lib/magic-importer.js b/js/lib/magic-importer.js index 0bd02e2..4c34095 100644 --- a/js/lib/magic-importer.js +++ b/js/lib/magic-importer.js @@ -1,5 +1,3 @@ -// @TODO: Add README info about filter importing and disableWarnings option. - import CssNodeExtract from 'css-node-extract'; import fs from 'fs'; import path from 'path'; From 567e42b1536067463198f23e220846f9c9dd1bbb Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:25:10 +0100 Subject: [PATCH 20/23] Update the general description to mention node importing. --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 62a0130..7481fa6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # node-sass-magic-importer [![Build Status](https://travis-ci.org/maoberlehner/node-sass-magic-importer.svg?branch=master)](https://travis-ci.org/maoberlehner/node-sass-magic-importer) -Custom node-sass importer for selector specific imports, module importing, globbing support and importing files only once. +Custom node-sass importer for selector specific imports, node importing, module importing, globbing support and importing files only once. ## Features This importer enables several comfort functions for importing SASS files more easily. diff --git a/package.json b/package.json index 3ef97d7..364b002 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-sass-magic-importer", - "description": "Custom node-sass importer for selector specific imports, module importing, globbing support, import files only once and importing of files with .css extension", + "description": "Custom node-sass importer for selector specific imports, node importing, module importing, globbing support and importing files only once", "keywords": [ "glob-importer", "importer", From f7688769147691930499a4883752b8513a1d8489 Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:29:22 +0100 Subject: [PATCH 21/23] Remove old upgrade instructions and add new instructions. --- README.md | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 7481fa6..7b7640c 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,9 @@ gulp.task('sass', function () { node-sass --importer node_modules/node-sass-magic-importer/dist/cli.js -o dist src/index.scss ``` +## Upgrade from 3.x.x to 4.x.x +No changes have to be made. + ## Upgrade from 2.x.x to 3.x.x Version 3.x.x changes the way how nested CSS selectors are imported. Up until version 2.x.x you had to specify all nested selectors if you wanted to import them. With version 3.x.x nested selectors are imported automatically if you import the parent selector. @@ -248,34 +251,6 @@ Version 3.x.x changes the way how nested CSS selectors are imported. Up until ve It is not possible anymore to import only certain nested selectors. If this is a major concern in your daily work feel free to create a new issue or pull request and I may think about making this configurable. -## Upgrade from 1.x.x to 2.x.x -Version 2.x.x does not return a node-sass custom importer function directly. Instead a function which can take a optional parameter for configuration is returned. When the function is executed, it returns a node-sass custom importer function. - -```node -sass.render({ - ... - // Old - importer: magicImporter, - magicImporter: { - cwd: process.cwd() - } - // New - importer: magicImporter({ - cwd: process.cwd() - }) - ... -}); -``` - -If you want to use the `node-sass-magic-importer` in combination with the node-sass CLI, you now have to specify the path to the `node-sass-magic-importer` CLI script. - -```bash -# Old -node-sass --importer node_modules/node-sass-magic-importer -o dist src/index.scss -# New -node-sass --importer node_modules/node-sass-magic-importer/dist/cli.js -o dist src/index.scss -``` - ## About ### Author Markus Oberlehner From 3861c7425bcc8e47a5a6291b4d5598b798a7c78d Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:30:19 +0100 Subject: [PATCH 22/23] Update dependencies. --- yarn.lock | 462 ++++++++++++++++++++++-------------------------------- 1 file changed, 191 insertions(+), 271 deletions(-) diff --git a/yarn.lock b/yarn.lock index 822fc05..5b4ba9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -31,23 +31,23 @@ acorn@^3.0.4: resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" acorn@^4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.3.tgz#1a3e850b428e73ba6b09d1cc527f5aaad4d03ef1" + version "4.0.4" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.4.tgz#17a8d6a7a6c4ef538b814ec9abac2779293bf30a" ajv-keywords@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.1.1.tgz#02550bc605a3e576041565628af972e06c549d50" + version "1.5.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.0.tgz#c11e6859eafff83e0dafc416929472eca946aa2c" ajv@^4.7.0: - version "4.7.7" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.7.7.tgz#4980d5f65ce90a2579532eec66429f320dea0321" + version "4.10.4" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.10.4.tgz#c0974dd00b3464984892d6010aa9c2c945933254" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" amdefine@>=0.0.4: - version "1.0.0" - resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.0.tgz#fd17474700cb5cc9c2b709f0be9d23ce3c198c33" + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" ansi-escapes@^1.1.0: version "1.4.0" @@ -58,8 +58,8 @@ ansi-regex@^1.0.0, ansi-regex@^1.1.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-1.1.1.tgz#41c847194646375e6a1a5d10c3ca054ef9fc980d" ansi-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.0.0.tgz#c5061b6e0ef8a81775e50f5d66151bf6bf371107" + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" ansi-styles@^2.2.1: version "2.2.1" @@ -86,13 +86,6 @@ array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" -array-index@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/array-index/-/array-index-1.0.0.tgz#ec56a749ee103e4e08c790b9c353df16055b97f9" - dependencies: - debug "^2.2.0" - es6-symbol "^3.0.2" - array-union@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" @@ -140,8 +133,8 @@ aws-sign2@~0.6.0: resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" aws4@^1.2.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.4.1.tgz#fde7d5292466d230e5ee0f4e038d9dfaab08fc61" + version "1.5.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755" babel-code-frame@^6.16.0, babel-code-frame@^6.20.0, babel-code-frame@^6.8.0: version "6.20.0" @@ -562,14 +555,10 @@ babel-types@^6.10.2, babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19 lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@6.14.1: +babylon@6.14.1, babylon@^6.11.0, babylon@^6.7.0: version "6.14.1" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.14.1.tgz#956275fab72753ad9b3435d7afe58f8bf0a29815" -babylon@^6.11.0, babylon@^6.7.0: - version "6.15.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" - balanced-match@^0.4.1: version "0.4.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" @@ -580,12 +569,6 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -bl@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/bl/-/bl-1.1.2.tgz#fdca871a99713aa00d19e3bbba41c44787a65398" - dependencies: - readable-stream "~2.0.5" - block-stream@*: version "0.0.9" resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" @@ -632,6 +615,10 @@ browser-stdout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" +buffer-shims@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" + builtin-modules@^1.0.0, builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -754,7 +741,7 @@ cheerio@0.22.0: lodash.reject "^4.4.0" lodash.some "^4.4.0" -circular-json@^0.3.0: +circular-json@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" @@ -791,10 +778,8 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" code-point-at@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.0.1.tgz#1104cd34f9b5b45d3eba88f1babc1924e1ce35fb" - dependencies: - number-is-nan "^1.0.0" + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" color-logger@0.0.3: version "0.0.3" @@ -833,12 +818,12 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" concat-stream@^1.4.6: - version "1.5.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.2.tgz#708978624d856af41a5a741defdd261da752c266" + version "1.6.0" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: - inherits "~2.0.1" - readable-stream "~2.0.0" - typedarray "~0.0.5" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" console-control-strings@^1.0.0, console-control-strings@~1.1.0: version "1.1.0" @@ -861,10 +846,6 @@ convert-source-map@^1.1.0: version "1.3.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.3.0.tgz#e9f3e9c6e2728efc2676696a70eb382f73106a67" -core-js@0.9.18: - version "0.9.18" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-0.9.18.tgz#13f458e430232b0f4ec1f480da7c2f5288e9d095" - core-js@^2.4.0: version "2.4.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" @@ -908,12 +889,10 @@ css-select@~1.2.0: nth-check "~1.0.1" css-selector-extract@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/css-selector-extract/-/css-selector-extract-2.0.1.tgz#f3c2646f424fb617e0dc2fce042da38163a7befa" + version "2.0.3" + resolved "https://registry.yarnpkg.com/css-selector-extract/-/css-selector-extract-2.0.3.tgz#ea21423706d5fcc2a7dc8876d989b0bb4eb4c59d" dependencies: - postcss "^5.2.6" - optionalDependencies: - esdoc "^0.4.8" + postcss "^5.2.8" css-what@2.1: version "2.1.0" @@ -952,12 +931,12 @@ d@^0.1.1, d@~0.1.1: es5-ext "~0.10.2" dashdash@^1.12.0: - version "1.14.0" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.0.tgz#29e486c5418bf0f356034a993d51686a33e84141" + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" dependencies: assert-plus "^1.0.0" -debug@2.2.0, debug@^2.1.1, debug@^2.2.0: +debug@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" dependencies: @@ -969,6 +948,12 @@ debug@2.3.3: dependencies: ms "0.7.2" +debug@^2.1.1, debug@^2.2.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b" + dependencies: + ms "0.7.2" + decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -979,7 +964,7 @@ deep-eql@^0.1.3: dependencies: type-detect "0.1.1" -deep-is@~0.1.2, deep-is@~0.1.3: +deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -1112,7 +1097,7 @@ es6-set@~0.1.3: es6-symbol "3" event-emitter "~0.3.4" -es6-symbol@3, es6-symbol@^3.0.2, es6-symbol@~3.1, es6-symbol@~3.1.0: +es6-symbol@3, es6-symbol@~3.1, es6-symbol@~3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.0.tgz#94481c655e7a7cad82eba832d97d5433496d7ffa" dependencies: @@ -1128,10 +1113,6 @@ es6-weak-map@^2.0.1: es6-iterator "2" es6-symbol "3" -escape-html@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.2.tgz#d77d32fa98e38c2f41ae85e9278e0e0e6ba1022c" - escape-html@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -1140,14 +1121,14 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -escodegen@1.7.0, escodegen@^1.6.1: - version "1.7.0" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.7.0.tgz#4e299d8cc33087b7f29c19e2b9e84362abe35453" +escodegen@^1.6.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018" dependencies: - esprima "^1.2.2" + esprima "^2.7.1" estraverse "^1.9.1" esutils "^2.0.2" - optionator "^0.5.0" + optionator "^0.8.1" optionalDependencies: source-map "~0.2.0" @@ -1160,23 +1141,6 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" -esdoc@^0.4.8: - version "0.4.8" - resolved "https://registry.yarnpkg.com/esdoc/-/esdoc-0.4.8.tgz#4972e2b6de85e2b929a330ed54b8c5f3fdcebd33" - dependencies: - cheerio "0.20.0" - color-logger "0.0.3" - core-js "0.9.18" - escape-html "1.0.2" - escodegen "1.7.0" - espree "2.2.0" - estraverse "4.1.0" - fs-extra "0.26.5" - ice-cap "0.0.4" - marked "0.3.5" - minimist "1.1.1" - taffydb "2.7.2" - esdoc@^0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/esdoc/-/esdoc-0.5.2.tgz#cbfd0b20e3d1cacc23c93c328eed987e21ba0067" @@ -1272,10 +1236,6 @@ eslint@^3.13.1: text-table "~0.2.0" user-home "^2.0.0" -espree@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-2.2.0.tgz#01dc927a7ea5081d1a7b6d610249e624e7fef3d6" - espree@^3.3.1: version "3.3.2" resolved "https://registry.yarnpkg.com/espree/-/espree-3.3.2.tgz#dbf3fadeb4ecb4d4778303e50103b3d36c88b89c" @@ -1283,11 +1243,7 @@ espree@^3.3.1: acorn "^4.0.1" acorn-jsx "^3.0.0" -esprima@^1.2.2: - version "1.2.5" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.2.5.tgz#0993502feaf668138325756f30f9a51feeec11e9" - -esprima@^2.6.0: +esprima@^2.6.0, esprima@^2.7.1: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" @@ -1298,10 +1254,6 @@ esrecurse@^4.1.0: estraverse "~4.1.0" object-assign "^4.0.1" -estraverse@4.1.0, estraverse@~4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.1.0.tgz#40f23a76092041be6467d7f235c933b670766e05" - estraverse@^1.9.1: version "1.9.3" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" @@ -1310,6 +1262,10 @@ estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" +estraverse@~4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.1.1.tgz#f6caca728933a850ef90661d0e17982ba47111a2" + estree-walker@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e" @@ -1337,13 +1293,9 @@ extsprintf@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" -fast-levenshtein@~1.0.0: - version "1.0.7" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.0.7.tgz#0178dcdee023b92905193af0959e8a7639cfdcb9" - fast-levenshtein@~2.0.4: - version "2.0.5" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.5.tgz#bd33145744519ab1c36c3ee9f31f08e9079b67f2" + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" figures@^1.3.5: version "1.7.0" @@ -1374,10 +1326,10 @@ findup@0.1.5: commander "~2.1.0" flat-cache@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.1.tgz#6c837d6225a7de5659323740b36d5361f71691ff" + version "1.2.2" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96" dependencies: - circular-json "^0.3.0" + circular-json "^0.3.1" del "^2.0.2" graceful-fs "^4.1.2" write "^0.2.1" @@ -1386,13 +1338,13 @@ forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" -form-data@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.0.0.tgz#6f0aebadcc5da16c13e1ecc11137d85f9b883b25" +form-data@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" dependencies: asynckit "^0.4.0" combined-stream "^1.0.5" - mime-types "^2.1.11" + mime-types "^2.1.12" formatio@1.1.1: version "1.1.1" @@ -1407,16 +1359,6 @@ foundation-sites@^6.3.0: jquery "^2.2.0" what-input "^4.0.3" -fs-extra@0.26.5: - version "0.26.5" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.26.5.tgz#53ac74667ca083fd2dc1712c813039ca32d69a7f" - dependencies: - graceful-fs "^4.1.2" - jsonfile "^2.1.0" - klaw "^1.0.0" - path-is-absolute "^1.0.0" - rimraf "^2.2.8" - fs-extra@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" @@ -1442,18 +1384,18 @@ function-bind@^1.0.2: version "1.1.0" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771" -gauge@~2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.6.0.tgz#d35301ad18e96902b4751dcbbe40f4218b942a46" +gauge@~2.7.1: + version "2.7.2" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.2.tgz#15cecc31b02d05345a5d6b0e171cdb3ad2307774" dependencies: aproba "^1.0.3" console-control-strings "^1.0.0" - has-color "^0.1.7" has-unicode "^2.0.0" object-assign "^4.1.0" signal-exit "^3.0.0" string-width "^1.0.1" strip-ansi "^3.0.1" + supports-color "^0.2.0" wide-align "^1.1.0" gaze@^1.0.0: @@ -1537,7 +1479,7 @@ glob@6.0.1: once "^1.3.0" path-is-absolute "^1.0.0" -glob@7.0.5, glob@~7.0.3: +glob@7.0.5: version "7.0.5" resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.5.tgz#b4202a69099bbb4d292a7c1b95b6682b67ebdc95" dependencies: @@ -1548,7 +1490,7 @@ glob@7.0.5, glob@~7.0.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@7.1.1, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1: +glob@7.1.1, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@~7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: @@ -1579,16 +1521,16 @@ globby@^5.0.0: pinkie-promise "^2.0.0" globule@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/globule/-/globule-1.0.0.tgz#f22aebaacce02be492453e979c3ae9b6983f1c6c" + version "1.1.0" + resolved "https://registry.yarnpkg.com/globule/-/globule-1.1.0.tgz#c49352e4dc183d85893ee825385eb994bb6df45f" dependencies: - glob "~7.0.3" - lodash "~4.9.0" - minimatch "~3.0.0" + glob "~7.1.1" + lodash "~4.16.4" + minimatch "~3.0.2" -graceful-fs@^4.1.2, graceful-fs@^4.1.6: - version "4.1.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.9.tgz#baacba37d19d11f9d146d3578bc99958c3787e29" +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" "graceful-readlink@>= 1.0.0": version "1.0.1" @@ -1613,10 +1555,6 @@ has-ansi@^2.0.0: dependencies: ansi-regex "^2.0.0" -has-color@^0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/has-color/-/has-color-0.1.7.tgz#67144a5260c34fc3cca677d041daf52fe7b78b2f" - has-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" @@ -1714,13 +1652,13 @@ indent-string@^2.1.0: repeating "^2.0.0" inflight@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.5.tgz#db3204cd5a9de2e6cd890b85c6e2f66bcf4f620a" + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" dependencies: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: +inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -1819,6 +1757,10 @@ is-fullwidth-code-point@^1.0.0: dependencies: number-is-nan "^1.0.0" +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: version "2.15.0" resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz#936edda3ca3c211fd98f3b2d3e08da43f7b2915b" @@ -1884,7 +1826,11 @@ jodid25519@^1.0.0: dependencies: jsbn "~0.1.0" -jquery@>=1.9.1, jquery@^2.2.0: +jquery@>=1.9.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.1.1.tgz#347c1c21c7e004115e0a4da32cece041fad3c8a3" + +jquery@^2.2.0: version "2.2.4" resolved "https://registry.yarnpkg.com/jquery/-/jquery-2.2.4.tgz#2c89d6889b5eac522a7eea32c14521559c6cbf02" @@ -1897,8 +1843,8 @@ js-tokens@^2.0.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-2.0.0.tgz#79903f5563ee778cc1162e6dcf1a0027c97f9cb5" js-yaml@^3.5.1: - version "3.6.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30" + version "3.7.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80" dependencies: argparse "^1.0.7" esprima "^2.6.0" @@ -1968,8 +1914,8 @@ jsonify@~0.0.0: resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" jsonpointer@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.0.tgz#6661e161d2fc445f19f98430231343722e1fcbd5" + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" jsprim@^1.2.2: version "1.3.1" @@ -1980,8 +1926,10 @@ jsprim@^1.2.2: verror "1.3.6" klaw@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.0.tgz#8857bfbc1d824badf13d3d0241d8bbe46fb12f73" + version "1.3.1" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" + optionalDependencies: + graceful-fs "^4.1.9" lazy-ass@0.5.3: version "0.5.3" @@ -2016,13 +1964,6 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -levn@~0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.2.5.tgz#ba8d339d0ca4a610e3a3f145b9caf48807155054" - dependencies: - prelude-ls "~1.1.0" - type-check "~0.3.1" - load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" @@ -2149,12 +2090,12 @@ lodash@3.10.1, lodash@^3.3.1: resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" lodash@^4.0.0, lodash@^4.1.0, lodash@^4.2.0, lodash@^4.3.0: - version "4.16.4" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.4.tgz#01ce306b9bad1319f2a5528674f88297aeb70127" + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" -lodash@~4.9.0: - version "4.9.0" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.9.0.tgz#4c20d742f03ce85dc700e0dd7ab9bcab85e6fc14" +lodash@~4.16.4: + version "4.16.6" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.6.tgz#d22c9ac660288f3843e16ba7d2b5d06cca27d777" lolex@1.3.2: version "1.3.2" @@ -2174,8 +2115,8 @@ loud-rejection@^1.0.0: signal-exit "^3.0.0" lru-cache@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.1.tgz#1343955edaf2e37d9b9e7ee7241e27c4b9fb72be" + version "4.0.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e" dependencies: pseudomap "^1.0.1" yallist "^2.0.0" @@ -2184,10 +2125,6 @@ map-obj@^1.0.0, map-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" -marked@0.3.5: - version "0.3.5" - resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.5.tgz#4113a15ac5d7bca158a5aae07224587b9fa15b94" - marked@0.3.6: version "0.3.6" resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.6.tgz#b2c6c618fccece4ef86c4fc6cb8a7cbf5aeda8d7" @@ -2207,17 +2144,17 @@ meow@^3.7.0: redent "^1.0.0" trim-newlines "^1.0.0" -mime-db@~1.24.0: - version "1.24.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.24.0.tgz#e2d13f939f0016c6e4e9ad25a8652f126c467f0c" +mime-db@~1.25.0: + version "1.25.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.25.0.tgz#c18dbd7c73a5dbf6f44a024dc0d165a1e7b1c392" -mime-types@^2.1.11, mime-types@~2.1.7: - version "2.1.12" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.12.tgz#152ba256777020dd4663f54c2e7bc26381e71729" +mime-types@^2.1.12, mime-types@~2.1.7: + version "2.1.13" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.13.tgz#e07aaa9c6c6b9a7ca3012c69003ad25a39e92a88" dependencies: - mime-db "~1.24.0" + mime-db "~1.25.0" -"minimatch@2 || 3", minimatch@^3.0.2, minimatch@^3.0.3, minimatch@~3.0.0: +"minimatch@2 || 3", minimatch@^3.0.2, minimatch@^3.0.3, minimatch@~3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" dependencies: @@ -2227,10 +2164,6 @@ minimist@0.0.8, minimist@~0.0.1: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.1.1.tgz#1bc2bc71658cdca5712475684363615b0b4f695b" - minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.3: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -2282,16 +2215,16 @@ mute-stream@0.0.5: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" nan@^2.3.2: - version "2.4.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.4.0.tgz#fb3c59d45fe4effe215f0b890f8adf6eb32d2232" + version "2.5.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.0.tgz#aa8f1e34531d807e9e27755b234b4a6ec0c152a8" natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" node-gyp@^3.3.1: - version "3.4.0" - resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-3.4.0.tgz#dda558393b3ecbbe24c9e6b8703c71194c63fa36" + version "3.5.0" + resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-3.5.0.tgz#a8fe5e611d079ec16348a3eb960e78e11c85274a" dependencies: fstream "^1.0.0" glob "^7.0.3" @@ -2299,9 +2232,8 @@ node-gyp@^3.3.1: minimatch "^3.0.2" mkdirp "^0.5.0" nopt "2 || 3" - npmlog "0 || 1 || 2 || 3" + npmlog "0 || 1 || 2 || 3 || 4" osenv "0" - path-array "^1.0.0" request "2" rimraf "2" semver "2.x || 3.x || 4 || 5" @@ -2338,8 +2270,8 @@ node-sass-selector-importer@^4.2.0: postcss-scss "^0.3.1" node-sass@^3.13.0: - version "3.13.0" - resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-3.13.0.tgz#d08b95bdebf40941571bd2c16a9334b980f8924f" + version "3.13.1" + resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-3.13.1.tgz#7240fbbff2396304b4223527ed3020589c004fc2" dependencies: async-foreach "^0.1.3" chalk "^1.1.1" @@ -2381,10 +2313,6 @@ node-sass@^4.3.0: sass-graph "^2.1.1" stdout-stream "^1.4.0" -node-uuid@~1.4.7: - version "1.4.7" - resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f" - "nopt@2 || 3": version "3.0.6" resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" @@ -2400,22 +2328,13 @@ normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -"npmlog@0 || 1 || 2 || 3": - version "3.1.2" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-3.1.2.tgz#2d46fa874337af9498a2f12bb43d8d0be4a36873" +"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" - gauge "~2.6.0" - set-blocking "~2.0.0" - -npmlog@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.0.tgz#e094503961c70c1774eb76692080e8d578a9f88f" - dependencies: - are-we-there-yet "~1.1.2" - console-control-strings "~1.1.0" - gauge "~2.6.0" + gauge "~2.7.1" set-blocking "~2.0.0" nth-check@~1.0.1: @@ -2429,8 +2348,8 @@ number-is-nan@^1.0.0: resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" "nwmatcher@>= 1.3.7 < 2.0.0": - version "1.3.8" - resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.3.8.tgz#34edb93de1aa6cb4448b573c9f2a059300241157" + version "1.3.9" + resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.3.9.tgz#8bab486ff7fa3dfd086656bbe8b17116d3692d2a" oauth-sign@~0.8.1: version "0.8.2" @@ -2457,18 +2376,7 @@ optimist@0.6.1: minimist "~0.0.1" wordwrap "~0.0.2" -optionator@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.5.0.tgz#b75a8995a2d417df25b6e4e3862f50aa88651368" - dependencies: - deep-is "~0.1.2" - fast-levenshtein "~1.0.0" - levn "~0.2.5" - prelude-ls "~1.1.1" - type-check "~0.3.1" - wordwrap "~0.0.2" - -optionator@^0.8.2: +optionator@^0.8.1, optionator@^0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" dependencies: @@ -2494,8 +2402,8 @@ os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" osenv@0: - version "0.1.3" - resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.3.tgz#83cf05c6d6458fc4d5ac6362ea325d92f2754217" + version "0.1.4" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" dependencies: os-homedir "^1.0.0" os-tmpdir "^1.0.0" @@ -2510,12 +2418,6 @@ parse5@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/parse5/-/parse5-1.5.1.tgz#9b7f3b0de32be78dc2401b17573ccaf0f6f59d94" -path-array@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-array/-/path-array-1.0.1.tgz#7e2f0f35f07a2015122b868b7eac0eb2c4fec271" - dependencies: - array-index "^1.0.0" - path-exists@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" @@ -2584,9 +2486,9 @@ postcss-scss@^0.4.0: dependencies: postcss "^5.2.5" -postcss@^5.2.4, postcss@^5.2.5, postcss@^5.2.6, postcss@^5.2.8: - version "5.2.8" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.8.tgz#05720c49df23c79bda51fd01daeb1e9222e94390" +postcss@^5.2.4, postcss@^5.2.5, postcss@^5.2.8: + version "5.2.10" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.10.tgz#b58b64e04f66f838b7bc7cb41f7dac168568a945" dependencies: chalk "^1.1.3" js-base64 "^2.1.9" @@ -2612,7 +2514,7 @@ pre-git@^3.12.0: validate-commit-msg "2.5.0" word-wrap "1.1.0" -prelude-ls@~1.1.0, prelude-ls@~1.1.1, prelude-ls@~1.1.2: +prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -2632,6 +2534,10 @@ pseudomap@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + q@1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/q/-/q-1.1.2.tgz#6357e291206701d99f197ab84e57e8ad196f2a89" @@ -2644,9 +2550,9 @@ q@2.0.3: pop-iterate "^1.0.1" weak-map "^1.0.5" -qs@~6.2.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.1.tgz#ce03c5ff0935bc1d9d69a9f14cbd18e568d67625" +qs@~6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442" quote@0.4.0: version "0.4.0" @@ -2680,10 +2586,11 @@ readable-stream@1.1: isarray "0.0.1" string_decoder "~0.10.x" -"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@~2.0.0, readable-stream@~2.0.5: - version "2.0.6" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" +"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e" dependencies: + buffer-shims "^1.0.0" core-util-is "~1.0.0" inherits "~2.0.1" isarray "~1.0.0" @@ -2766,17 +2673,16 @@ repeating@^2.0.0: is-finite "^1.0.0" request@2, request@^2.55.0, request@^2.61.0: - version "2.75.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93" + version "2.79.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de" dependencies: aws-sign2 "~0.6.0" aws4 "^1.2.1" - bl "~1.1.2" caseless "~0.11.0" combined-stream "~1.0.5" extend "~3.0.0" forever-agent "~0.6.1" - form-data "~2.0.0" + form-data "~2.1.1" har-validator "~2.0.6" hawk "~3.1.3" http-signature "~1.1.0" @@ -2784,12 +2690,12 @@ request@2, request@^2.55.0, request@^2.61.0: isstream "~0.1.2" json-stringify-safe "~5.0.1" mime-types "~2.1.7" - node-uuid "~1.4.7" oauth-sign "~0.8.1" - qs "~6.2.0" + qs "~6.3.0" stringstream "~0.0.4" tough-cookie "~2.3.0" tunnel-agent "~0.4.1" + uuid "^3.0.0" require-directory@^2.1.1: version "2.1.1" @@ -2804,8 +2710,8 @@ require-relative@0.8.7: resolved "https://registry.yarnpkg.com/require-relative/-/require-relative-0.8.7.tgz#7999539fc9e047a37928fa196f8e1563dabd36de" require-uncached@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.2.tgz#67dad3b733089e77030124678a459589faf6a7ec" + version "1.0.3" + resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" dependencies: caller-path "^0.1.0" resolve-from "^1.0.0" @@ -2815,8 +2721,8 @@ resolve-from@^1.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" resolve@^1.1.6, resolve@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + version "1.2.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c" restore-cursor@^1.0.1: version "1.0.1" @@ -2887,11 +2793,7 @@ semver-regex@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-1.0.0.tgz#92a4969065f9c70c694753d55248fc68f8f652c9" -"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5": - version "5.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" - -semver@5.1.0: +"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.1.0.tgz#85f2cf8550465c4df000cf7d86f6b054106ab9e5" @@ -2904,16 +2806,16 @@ shelljs@0.6.0: resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.6.0.tgz#ce1ed837b4b0e55b5ec3dab84251ab9dbdc0c7ec" shelljs@^0.7.5: - version "0.7.5" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.5.tgz#2eef7a50a21e1ccf37da00df767ec69e30ad0675" + version "0.7.6" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.6.tgz#379cccfb56b91c8601e4793356eb5382924de9ad" dependencies: glob "^7.0.0" interpret "^1.0.0" rechoir "^0.6.2" signal-exit@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.1.tgz#5a4c884992b63a7acd9badb7894c3ee9cfccad81" + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" simple-commit-message@2.2.1: version "2.2.1" @@ -2952,8 +2854,8 @@ sntp@1.x.x: hoek "2.x.x" source-map-support@^0.4.0, source-map-support@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.3.tgz#693c8383d4389a4569486987c219744dfc601685" + version "0.4.8" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.8.tgz#4871918d8a3af07289182e974e32844327b2e98b" dependencies: source-map "^0.5.3" @@ -2990,8 +2892,8 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" sshpk@^1.7.0: - version "1.10.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.10.1.tgz#30e1a5d329244974a1af61511339d595af6638b0" + version "1.10.2" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.10.2.tgz#d5a804ce22695515638e798dbe23273de070a5fa" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -3018,6 +2920,13 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" +string-width@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.0.0.tgz#635c5436cc72a6e0c387ceca278d4e2eec52687e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^3.0.0" + string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" @@ -3064,24 +2973,28 @@ supports-color@3.1.2, supports-color@^3.1.2: dependencies: has-flag "^1.0.0" +supports-color@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" + supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" "symbol-tree@>= 3.1.0 < 4.0.0": - version "3.1.4" - resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.1.4.tgz#02b279348d337debc39694c5c95f882d448a312a" + version "3.2.1" + resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.1.tgz#8549dd1d01fa9f893c18cc9ab0b106b4d9b168cb" table@^3.7.8: - version "3.8.0" - resolved "https://registry.yarnpkg.com/table/-/table-3.8.0.tgz#252166c7f3286684a9d561b0f3a8929caf3a997b" + version "3.8.3" + resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" dependencies: ajv "^4.7.0" ajv-keywords "^1.0.0" chalk "^1.1.1" lodash "^4.0.0" slice-ansi "0.0.4" - string-width "^1.0.1" + string-width "^2.0.0" taffydb@2.7.2: version "2.7.2" @@ -3112,8 +3025,10 @@ to-fast-properties@^1.0.1: resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" tough-cookie@^2.2.0, tough-cookie@~2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.1.tgz#99c77dfbb7d804249e8a299d4cb0fd81fef083fd" + version "2.3.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" + dependencies: + punycode "^1.4.1" tr46@~0.0.1: version "0.0.3" @@ -3124,18 +3039,18 @@ trim-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" tryit@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.2.tgz#c196b0073e6b1c595d93c9c830855b7acc32a453" + version "1.0.3" + resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" tunnel-agent@~0.4.1: version "0.4.3" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.3" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.3.tgz#3da382f670f25ded78d7b3d1792119bca0b7132d" + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -type-check@~0.3.1, type-check@~0.3.2: +type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" dependencies: @@ -3149,7 +3064,7 @@ type-detect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2" -typedarray@~0.0.5: +typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" @@ -3173,6 +3088,10 @@ util-deprecate@~1.0.1: dependencies: inherits "2.0.1" +uuid@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + validate-commit-msg@2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/validate-commit-msg/-/validate-commit-msg-2.5.0.tgz#a7d0a68aa3917171b560664689a2ac59c25908b6" @@ -3216,8 +3135,8 @@ which-module@^1.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" which@1, which@^1.2.9: - version "1.2.11" - resolved "https://registry.yarnpkg.com/which/-/which-1.2.11.tgz#c8b2eeea6b8c1659fa7c1dd4fdaabe9533dc5e8b" + version "1.2.12" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192" dependencies: isexe "^1.1.1" @@ -3244,10 +3163,11 @@ wordwrap@~1.0.0: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" wrap-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.0.0.tgz#7d30f8f873f9a5bbc3a64dabc8d177e071ae426f" + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" dependencies: string-width "^1.0.1" + strip-ansi "^3.0.1" wrappy@1: version "1.0.2" From c33b9493dea97d9c94a2e260fa9c0f39a14b0f9a Mon Sep 17 00:00:00 2001 From: Markus Oberlehner Date: Sat, 14 Jan 2017 19:31:16 +0100 Subject: [PATCH 23/23] Bump version number to 4.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 364b002..5280d81 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "sass", "selector-importer" ], - "version": "3.1.0", + "version": "4.0.0", "author": "Markus Oberlehner", "homepage": "https://github.com/maoberlehner/node-sass-magic-importer", "license": "MIT",