pax_global_header00006660000000000000000000000064130502070460014507gustar00rootroot0000000000000052 comment=18d08099ad6df882a9b7c5f6cdb69aab5831cedd postcss-load-plugins-2.3.0/000077500000000000000000000000001305020704600156035ustar00rootroot00000000000000postcss-load-plugins-2.3.0/.editorconfig000066400000000000000000000002741305020704600202630ustar00rootroot00000000000000root = true [*] charset = utf-8 indent_size = 2 end_of_line = lf indent_style = space trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false postcss-load-plugins-2.3.0/.github/000077500000000000000000000000001305020704600171435ustar00rootroot00000000000000postcss-load-plugins-2.3.0/.github/ISSUE_TEMPLATE.md000066400000000000000000000022251305020704600216510ustar00rootroot00000000000000## Problem Briefly describe the issue you are experiencing (or the feature you want to see added to the plugin). Tell us what you were trying to do and what happened instead. Remember, this is _not_ a place to ask questions. For that, go to http://gitter.im/postcss/postcss ## Details Describe in more detail the problem you have been experiencing, if necessary. ## Error Logs Create a [gist](https://gist.github.com) which is a paste of your **full** logs(_result.warnings_ (PostCSS Warnings), _result.messages_ (PostCSS Messages), _result.css_ (CSS)), and link them here. Do **not** paste your full logs here, as it will make this issue long and hard to read! If you are reporting a bug, **always** include logs! ## Issue [ Code ] Please remember that, with sample code; it's easier to reproduce bug and much faster to fix it. Please refer to a simple code example. ```bash $ git clone https://github.com// ``` ## Environment Please provide information about your environment. | OS | Node | npm | PostCSS | |:---------------:|:---------:|:---------:|:---------:| | [name][version] | [version] | [version] | [version] | postcss-load-plugins-2.3.0/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000024271305020704600227510ustar00rootroot00000000000000## Proposed changes Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. ## Types of changes What types of changes does your code introduce _Put an `x` in the boxes that apply_ - [ ] Bug (non-breaking change which fixes an issue) - [ ] Feature (non-breaking change which adds functionality) - [ ] Breaking Change (fix or feature which changes existing functionality) ## Checklist _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is a reminder of what we are going to look for before merging your code._ - [ ] I have read the [CONTRIBUTING](/CONTRIBUTING.md) guide - [ ] Lint and unit tests pass with my changes - [ ] I have added tests that prove my fix is effective/works - [ ] I have added necessary documentation (if appropriate) - [ ] Any dependent changes are merged and published in downstream modules ## Further comments If this is a large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... ### Reviewers: @michael-ciniawsky, ... postcss-load-plugins-2.3.0/.gitignore000066400000000000000000000001371305020704600175740ustar00rootroot00000000000000# OS .DS_Store ._* # NODEJS .nyc_output npm-debug.log dmd coverage jsdoc-api node_modules postcss-load-plugins-2.3.0/.npmignore000066400000000000000000000002131305020704600175760ustar00rootroot00000000000000# FILES .travis.yml .gitignore .editorconfig npm-debug.log # DIRECTORIES .github .nyc_output dmd test coverage jsdoc-api node_modules postcss-load-plugins-2.3.0/.travis.yml000066400000000000000000000003421305020704600177130ustar00rootroot00000000000000language: node_js node_js: - node - 6 - 4 cache: directories: - node_modules after_success: - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' notifications: email: false postcss-load-plugins-2.3.0/CHANGELOG.md000066400000000000000000000027571305020704600174270ustar00rootroot00000000000000 # [2.3.0](https://github.com/michael-ciniawsky/postcss-load-plugins/compare/v2.2.0...v2.3.0) (2017-02-13) ### Features * **index:** Allow extensions for .postcssrc ([65cc0d0](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/65cc0d0)) # 2.2.0 (2017-01-11) ### Features * **index:** expose config file ([c643172](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/c643172)) * **index:** improve error handling ([f3a4048](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/f3a4048)) * **lib:** improve error handling ([a64bb03](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/a64bb03)) # 2.1.0 (2016-12-05) ### Bug Fixes * **index:** set NODE_ENV if undefined ([920f806](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/920f806)) * **index:** support node v0.12 ([e31fab3](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/e31fab3)) * **lib/plugins:** support node v0.12 ([c440e6b](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/c440e6b)) * **loadPlugins:** add object-assign polyfill ([acd3f84](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/acd3f84)) * **plugins:** check for plugin.default ([024e8c7](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/024e8c7)) ### Features * function support, jsdoc, cleanups ([f637d60](https://github.com/michael-ciniawsky/postcss-load-plugins/commit/f637d60)) postcss-load-plugins-2.3.0/INDEX.md000066400000000000000000000021401305020704600167710ustar00rootroot00000000000000## Functions
pluginsrc(ctx, path, options)Array

Autoload Plugins for PostCSS

plugins(config)Array
## pluginsrc(ctx, path, options) ⇒ Array Autoload Plugins for PostCSS **Kind**: global function **Returns**: Array - config PostCSS Plugins **Requires**: module:cosmiconfig, module:object-assign, module:./lib/plugins.js **Version**: 2.3.0 **Author:** Michael Ciniawsky (@michael-ciniawsky) **License**: MIT | Param | Type | Description | | --- | --- | --- | | ctx | Object | Context | | path | String | Directory | | options | Object | Options | ## plugins(config) ⇒ Array **Kind**: global function **Returns**: Array - plugins PostCSS Plugins | Param | Type | Description | | --- | --- | --- | | config | Object | PostCSS Config | postcss-load-plugins-2.3.0/LICENSE000066400000000000000000000021151305020704600166070ustar00rootroot00000000000000License (MIT) Copyright (c) Michael Ciniawsky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. postcss-load-plugins-2.3.0/README.md000066400000000000000000000121151305020704600170620ustar00rootroot00000000000000[![npm][npm]][npm-url] [![node][node]][node-url] [![deps][deps]][deps-url] [![tests][tests]][tests-url] [![coverage][cover]][cover-url] [![code style][style]][style-url] [![chat][chat]][chat-url]

Load Plugins

Install

```bash npm i -D postcss-load-plugins ```

Usage

``` npm i -S|-D postcss-plugin ``` Install plugins and save them to your ***package.json*** dependencies/devDependencies. ### `package.json` Create **`postcss`** section in your projects **`package.json`**. ``` App |– client |– public | |- package.json ``` ```json { "postcss": { "plugins": { "postcss-plugin": {} } } } ``` ### `.postcssrc` Create a **`.postcssrc`** file. ``` App |– client |– public | |- (.postcssrc|.postcssrc.json|.postcssrc.yaml) |- package.json ``` **`JSON`** ```json { "plugins": { "postcss-plugin": {} } } ``` **`YAML`** ```yaml plugins: postcss-plugin: {} ``` ### `postcss.config.js` or `.postcssrc.js` You may need some JavaScript logic to generate your config. For this case you can use a file named **`postcss.config.js`** or **`.postcssrc.js`**. ``` App |– client |– public | |- (postcss.config.js|.postcssrc.js) |- package.json ``` Plugins can be loaded in either using an `{Object}` or an `{Array}`. ##### `{Object}` ```js module.exports = (ctx) => ({ plugins: { 'postcss-plugin': ctx.plugin } }) ``` ##### `{Array}` ```js module.exports = (ctx) => ({ plugins: [ require('postcss-plugin')(ctx.plugin) ] }) ```

Options

Plugin **options** can take the following values. **`{}`: Plugin loads with defaults** ```js 'postcss-plugin': {} || null ``` > :warning: `{}` must be an **empty** object **`{Object}`: Plugin loads with options** ```js 'postcss-plugin': { option: '', option: '' } ``` **`false`: Plugin will not be loaded** ```js 'postcss-plugin': false ``` ### Order Plugin **order** is determined by declaration in the plugins section. ```js { plugins: { 'postcss-plugin': {}, // plugins[0] 'postcss-plugin': {}, // plugins[1] 'postcss-plugin': {} // plugins[2] } } ``` ### Context When using a function `(postcss.config.js)`, it is possible to pass context to `postcss-load-plugins`, which will be evaluated before loading your plugins. By default `ctx.env (process.env.NODE_ENV)` and `ctx.cwd (process.cwd())` are available.

Examples

**`postcss.config.js`** ```js module.exports = (ctx) => ({ plugins: { postcss-import: {}, postcss-modules: ctx.modules ? {} : false, cssnano: ctx.env === 'production' ? {} : false } }) ``` ### ```js const { readFileSync } = require('fs') const postcss = require('postcss') const pluginsrc = require('postcss-load-plugins') const css = readFileSync('index.css', 'utf8') const ctx = { modules: true } pluginsrc(ctx).then((plugins) => { postcss(plugins) .process(css) .then((result) => console.log(result.css)) }) ```

Maintainers


Michael Ciniawsky

Mateusz Derks

Contributors


Diogo Franco
[npm]: https://img.shields.io/npm/v/postcss-load-plugins.svg [npm-url]: https://npmjs.com/package/postcss-load-plugins [node]: https://img.shields.io/node/v/postcss-load-plugins.svg [node-url]: https://nodejs.org/ [deps]: https://david-dm.org/michael-ciniawsky/postcss-load-plugins.svg [deps-url]: https://david-dm.org/michael-ciniawsky/postcss-load-plugins [tests]: http://img.shields.io/travis/michael-ciniawsky/postcss-load-plugins.svg [tests-url]: https://travis-ci.org/michael-ciniawsky/postcss-load-plugins [cover]: https://coveralls.io/repos/github/michael-ciniawsky/postcss-load-plugins/badge.svg [cover-url]: https://coveralls.io/github/michael-ciniawsky/postcss-load-plugins [style]: https://img.shields.io/badge/code%20style-standard-yellow.svg [style-url]: http://standardjs.com/ [chat]: https://img.shields.io/gitter/room/postcss/postcss.svg [chat-url]: https://gitter.im/postcss/postcss postcss-load-plugins-2.3.0/index.js000066400000000000000000000030071305020704600172500ustar00rootroot00000000000000// ------------------------------------ // # POSTCSS - LOAD PLUGINS - INDEX // ------------------------------------ 'use strict' var resolve = require('path').resolve var config = require('cosmiconfig') var assign = require('object-assign') var loadPlugins = require('./lib/plugins') /** * Autoload Plugins for PostCSS * * @author Michael Ciniawsky (@michael-ciniawsky) * @license MIT * * @module postcss-load-plugins * @version 2.3.0 * * @requires cosmiconfig * @requires object-assign * @requires ./lib/plugins.js * * @method pluginsrc * * @param {Object} ctx Context * @param {String} path Directory * @param {Object} options Options * * @return {Array} config PostCSS Plugins */ module.exports = function pluginsrc (ctx, path, options) { ctx = assign({ cwd: process.cwd(), env: process.env.NODE_ENV }, ctx) path = path ? resolve(path) : process.cwd() options = assign({ rcExtensions: true }, options) if (!ctx.env) process.env.NODE_ENV = 'development' var file return config('postcss', options) .load(path) .then(function (result) { if (!result) throw new Error('No PostCSS Config found in: ' + path) file = result ? result.filepath : '' return result ? result.config : {} }) .then(function (plugins) { if (typeof plugins === 'function') plugins = plugins(ctx) else plugins = assign(plugins, ctx) if (!plugins.plugins) plugins.plugins = [] return { plugins: loadPlugins(plugins), file: file } }) } postcss-load-plugins-2.3.0/lib/000077500000000000000000000000001305020704600163515ustar00rootroot00000000000000postcss-load-plugins-2.3.0/lib/plugins.js000066400000000000000000000040471305020704600203750ustar00rootroot00000000000000// ------------------------------------ // # POSTCSS - LOAD PLUGINS - PLUGINS // ------------------------------------ 'use strict' /** * @method plugins * * @param {Object} config PostCSS Config * * @return {Array} plugins PostCSS Plugins */ module.exports = function plugins (config) { var plugins = [] if (Array.isArray(config.plugins)) { plugins = config.plugins.filter(Boolean) if (plugins.length && plugins.length > 0) { plugins.forEach(function (plugin, i) { if (!plugin) throw new Error('Loading PostCSS Plugin failed') if (plugin.postcss) plugin = plugin.postcss if (plugin.default) plugin = plugin.default if ( !(typeof plugin === 'object' && Array.isArray(plugin.plugins) || typeof plugin === 'function') ) { throw new TypeError('Invalid PostCSS Plugin found: ' + '[' + i + ']') } }) } return plugins } else { config = config.plugins var load = function (plugin, options) { if (options === null || Object.keys(options).length === 0) { try { return require(plugin) } catch (err) { err.message = 'Loading PostCSS Plugin failed: ' + err.message throw err } } else { try { return require(plugin)(options) } catch (err) { err.message = 'Loading PostCSS Plugin failed: ' + err.message throw err } } } Object.keys(config) .filter(function (plugin) { return config[plugin] !== false ? plugin : '' }) .forEach(function (plugin, i) { plugin = load(plugin, config[plugin]) if (plugin.postcss) plugin = plugin.postcss if (plugin.default) plugin = plugin.default if ( !(typeof plugin === 'object' && Array.isArray(plugin.plugins) || typeof plugin === 'function') ) { throw new TypeError('Invalid PostCSS Plugin found: ' + '[' + i + ']') } return plugins.push(plugin) }) return plugins } } postcss-load-plugins-2.3.0/logo.svg000066400000000000000000000034611305020704600172700ustar00rootroot00000000000000 postcss-load-plugins-2.3.0/package.json000066400000000000000000000032771305020704600201020ustar00rootroot00000000000000{ "name": "postcss-load-plugins", "version": "2.3.0", "description": "Autoload Plugins for PostCSS", "engines": { "node": ">=0.12" }, "main": "index.js", "scripts": { "lint": "standard", "test": "nyc ava -v test/err/index.js test/rc/index.js test/pkg/index.js test/js/**/index.js", "logs": "standard-changelog -i CHANGELOG.md -w", "docs": "jsdoc2md index.js lib/plugins.js > INDEX.md", "clean": "rm -rf .nyc_output coverage jsdoc-api dmd", "start": "sudo npm run clean && npm run lint && sudo npm test" }, "dependencies": { "cosmiconfig": "^2.1.1", "object-assign": "^4.1.0" }, "devDependencies": { "ava": "^0.18.1", "coveralls": "^2.11.16", "cssnano": "^3.10.0", "jsdoc-to-markdown": "^3.0.0", "nyc": "^10.1.0", "postcss": "^5.2.12", "postcss-cssnext": "^2.8.0", "postcss-import": "^9.1.0", "postcss-nested": "^1.0.0", "postcss-sprites": "^4.2.0", "standard": "^8.6.0", "standard-changelog": "0.0.1", "sugarss": "^0.2.0" }, "files": [ "lib", "index.js" ], "keywords": [ "postcss", "postcss-plugin" ], "author": { "name": "Michael Ciniawky", "email": "michael.ciniawsky@gmail.com" }, "contributors": [ { "name": "Mateusz Derks", "url": "http://ertrzyiks.me" }, { "name": "Diogo Franco", "email": "diogomfranco@gmail.com" } ], "repository": { "type": "git", "url": "https://github.com/michael-ciniawsky/postcss-load-plugins.git" }, "bugs": { "url": "https://github.com/michael-ciniawsky/postcss-load-plugins/issues" }, "homepage": "https://github.com/michael-ciniawsky/postcss-load-plugins#readme", "license": "MIT" } postcss-load-plugins-2.3.0/test/000077500000000000000000000000001305020704600165625ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/err/000077500000000000000000000000001305020704600173525ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/err/array/000077500000000000000000000000001305020704600204705ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/err/array/postcss.config.js000066400000000000000000000001461305020704600237710ustar00rootroot00000000000000module.exports = function (ctx) { return { plugins: [ require('../plugin.js') ] } } postcss-load-plugins-2.3.0/test/err/index.js000066400000000000000000000025411305020704600210210ustar00rootroot00000000000000// ------------------------------------- // # POSTCSS - LOAD PLUGINS - TEST - ERR // ------------------------------------- 'use strict' var test = require('ava') var pluginsrc = require('../..') test('No Config - {Error} - Load Plugins', function (t) { return pluginsrc({}, 'test').catch(function (err) { t.is(err.message, 'No PostCSS Config found in: /home/travis/build/michael-ciniawsky/postcss-load-plugins/test') }) }) test('No Plugin - {Error} - Load Plugins', function (t) { return pluginsrc({}, 'test/err/object').catch(function (err) { t.is(err.message, "Loading PostCSS Plugin failed: Cannot find module 'no plugin'") }) }) test('No Plugin (Options) - {Error} - Load Plugins', function (t) { var ctx = { next: 1 } return pluginsrc(ctx, 'test/err/object').catch(function (err) { t.is(err.message, "Loading PostCSS Plugin failed: Cannot find module 'no plugin options'") }) }) test('Invalid Plugin {Object} - {Error} - Load Plugins', function (t) { var ctx = { next: 2 } return pluginsrc(ctx, 'test/err/object').catch(function (err) { t.is(err.message, 'Invalid PostCSS Plugin found: [0]') }) }) test('Invalid Plugin {Array} - {Error} - Load Plugins', function (t) { var ctx = { next: 2 } return pluginsrc(ctx, 'test/err/array').catch(function (err) { t.is(err.message, 'Invalid PostCSS Plugin found: [0]') }) }) postcss-load-plugins-2.3.0/test/err/object/000077500000000000000000000000001305020704600206205ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/err/object/postcss.config.js000066400000000000000000000003351305020704600241210ustar00rootroot00000000000000module.exports = function (ctx) { return { plugins: { 'no plugin': ctx.next ? false : {}, 'no plugin options': ctx.next === 2 ? false : { option: 'value' }, '../test/err/plugin.js': {} } } } postcss-load-plugins-2.3.0/test/err/plugin.js000066400000000000000000000000241305020704600212020ustar00rootroot00000000000000module.exports = {} postcss-load-plugins-2.3.0/test/js/000077500000000000000000000000001305020704600171765ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/array/000077500000000000000000000000001305020704600203145ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/array/expect/000077500000000000000000000000001305020704600216045ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/array/expect/index.css000066400000000000000000000001641305020704600234260ustar00rootroot00000000000000.import{color:#daa520}.test{color:cyan}.test__yellow{color:#ff0}.test__navy{color:navy}.test__crimson{color:crimson}postcss-load-plugins-2.3.0/test/js/array/expect/index.sss000066400000000000000000000001641305020704600234460ustar00rootroot00000000000000.import{color:#daa520}.test{color:cyan}.test__yellow{color:#ff0}.test__navy{color:navy}.test__crimson{color:crimson}postcss-load-plugins-2.3.0/test/js/array/fixtures/000077500000000000000000000000001305020704600221655ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/array/fixtures/imports/000077500000000000000000000000001305020704600236625ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/array/fixtures/imports/section.css000066400000000000000000000000401305020704600260320ustar00rootroot00000000000000.import { color: goldenrod; } postcss-load-plugins-2.3.0/test/js/array/fixtures/imports/section.sss000066400000000000000000000000331305020704600260540ustar00rootroot00000000000000.import color: goldenrod postcss-load-plugins-2.3.0/test/js/array/fixtures/index.css000066400000000000000000000002511305020704600240040ustar00rootroot00000000000000@import 'imports/section.css'; .test { color: cyan; &__yellow { color: yellow; } &__navy { color: navy; } &__crimson { color: crimson; } } postcss-load-plugins-2.3.0/test/js/array/fixtures/index.sss000066400000000000000000000002161305020704600240250ustar00rootroot00000000000000@import 'imports/section.sss' .test color: cyan &__yellow color: yellow &__navy color: navy &__crimson color: crimson postcss-load-plugins-2.3.0/test/js/array/index.js000066400000000000000000000047231305020704600217670ustar00rootroot00000000000000// ------------------------------------ // # POSTCSS - LOAD PlUGINS - TEST - JS // ------------------------------------ 'use strict' var test = require('ava') var path = require('path') var read = require('fs').readFileSync var postcss = require('postcss') var pluginsrc = require('../../..') var fixture = function (file) { return read(path.join(__dirname, 'fixtures', file), 'utf8') } var expect = function (file) { return read(path.join(__dirname, 'expect', file), 'utf8') } test('postcss.config.js - {Function} - Load Plugins', function (t) { return pluginsrc({}, 'test/js/array').then(function (config) { var plugins = config.plugins t.is(plugins.length, 4) t.is(plugins[0].postcssPlugin, 'postcss-import') t.is(plugins[1].postcss.postcssPlugin, 'postcss-nested') t.is(plugins[2].postcssPlugin, 'postcss-sprites') t.is(plugins[3].postcssPlugin, 'postcss-cssnext') t.is(config.file, path.resolve('test/js/array/postcss.config.js')) }) }) test('postcss.config.js - {Function} - Load Plugins', function (t) { process.env.NODE_ENV = 'production' return pluginsrc({}, 'test/js/array').then(function (config) { var plugins = config.plugins t.is(plugins.length, 5) t.is(plugins[0].postcssPlugin, 'postcss-import') t.is(plugins[1].postcss.postcssPlugin, 'postcss-nested') t.is(plugins[2].postcssPlugin, 'postcss-sprites') t.is(plugins[3].postcssPlugin, 'postcss-cssnext') t.is(plugins[4].postcssPlugin, 'cssnano') t.is(config.file, path.resolve('test/js/array/postcss.config.js')) }) }) test('postcss.config.js - {Function} - Process CSS', function (t) { return pluginsrc({}, 'test/js/array').then(function (config) { var plugins = config.plugins var options = { from: 'test/js/array/fixtures/index.css', to: 'test/js/array/expect/index.css' } return postcss(plugins) .process(fixture('index.css'), options) .then(function (result) { t.is(expect('index.css'), result.css) }) }) }) test('postcss.config.js - {Function} - Process SSS', function (t) { return pluginsrc({}, 'test/js/array').then(function (config) { var plugins = config.plugins var options = { parser: require('sugarss'), from: 'test/js/array/fixtures/index.sss', to: 'test/js/array/expect/index.sss' } return postcss(plugins) .process(fixture('index.sss'), options) .then(function (result) { t.is(expect('index.sss'), result.css) }) }) }) postcss-load-plugins-2.3.0/test/js/array/postcss.config.js000066400000000000000000000006131305020704600236140ustar00rootroot00000000000000module.exports = function (ctx) { return { plugins: [ require('postcss-import')(), // simulate the case of require('doiuse') without actually requiring it { postcss: require('postcss-nested')() }, require('postcss-sprites')(), require('postcss-cssnext')({ warnForDuplicates: false }), ctx.env === 'production' ? require('cssnano')() : false ] } } postcss-load-plugins-2.3.0/test/js/object/000077500000000000000000000000001305020704600204445ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/object/expect/000077500000000000000000000000001305020704600217345ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/object/expect/index.css000066400000000000000000000001641305020704600235560ustar00rootroot00000000000000.import{color:#daa520}.test{color:cyan}.test__yellow{color:#ff0}.test__navy{color:navy}.test__crimson{color:crimson}postcss-load-plugins-2.3.0/test/js/object/expect/index.sss000066400000000000000000000001641305020704600235760ustar00rootroot00000000000000.import{color:#daa520}.test{color:cyan}.test__yellow{color:#ff0}.test__navy{color:navy}.test__crimson{color:crimson}postcss-load-plugins-2.3.0/test/js/object/fixtures/000077500000000000000000000000001305020704600223155ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/object/fixtures/imports/000077500000000000000000000000001305020704600240125ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/js/object/fixtures/imports/section.css000066400000000000000000000000401305020704600261620ustar00rootroot00000000000000.import { color: goldenrod; } postcss-load-plugins-2.3.0/test/js/object/fixtures/imports/section.sss000066400000000000000000000000331305020704600262040ustar00rootroot00000000000000.import color: goldenrod postcss-load-plugins-2.3.0/test/js/object/fixtures/index.css000066400000000000000000000002511305020704600241340ustar00rootroot00000000000000@import 'imports/section.css'; .test { color: cyan; &__yellow { color: yellow; } &__navy { color: navy; } &__crimson { color: crimson; } } postcss-load-plugins-2.3.0/test/js/object/fixtures/index.sss000066400000000000000000000002161305020704600241550ustar00rootroot00000000000000@import 'imports/section.sss' .test color: cyan &__yellow color: yellow &__navy color: navy &__crimson color: crimson postcss-load-plugins-2.3.0/test/js/object/index.js000066400000000000000000000047151305020704600221200ustar00rootroot00000000000000// ------------------------------------ // # POSTCSS - LOAD PlUGINS - TEST - JS // ------------------------------------ 'use strict' var test = require('ava') var path = require('path') var read = require('fs').readFileSync var postcss = require('postcss') var pluginsrc = require('../../..') var fixture = function (file) { return read(path.join(__dirname, 'fixtures', file), 'utf8') } var expect = function (file) { return read(path.join(__dirname, 'expect', file), 'utf8') } test('postcss.config.js - {Function} - Load Plugins', function (t) { return pluginsrc({}, 'test/js/object').then(function (config) { var plugins = config.plugins t.is(plugins.length, 4) t.is(plugins[0].postcssPlugin, 'postcss-import') t.is(plugins[1].postcssPlugin, 'postcss-nested') t.is(plugins[2].postcssPlugin, 'postcss-sprites') t.is(plugins[3].postcssPlugin, 'postcss-cssnext') t.is(config.file, path.resolve('test/js/object/postcss.config.js')) }) }) test('postcss.config.js - {Function} - Load Plugins', function (t) { process.env.NODE_ENV = 'production' return pluginsrc({}, 'test/js/object').then(function (config) { var plugins = config.plugins t.is(plugins.length, 5) t.is(plugins[0].postcssPlugin, 'postcss-import') t.is(plugins[1].postcssPlugin, 'postcss-nested') t.is(plugins[2].postcssPlugin, 'postcss-sprites') t.is(plugins[3].postcssPlugin, 'postcss-cssnext') t.is(plugins[4].postcssPlugin, 'cssnano') t.is(config.file, path.resolve('test/js/object/postcss.config.js')) }) }) test('postcss.config.js - {Function} - Process CSS', function (t) { return pluginsrc({}, 'test/js/object').then(function (config) { var plugins = config.plugins var options = { from: 'test/js/object/fixtures/index.css', to: 'test/js/object/expect/index.css' } return postcss(plugins) .process(fixture('index.css'), options) .then(function (result) { t.is(expect('index.css'), result.css) }) }) }) test('postcss.config.js - {Function} - Process SSS', function (t) { return pluginsrc({}, 'test/js/object').then(function (config) { var plugins = config.plugins var options = { parser: require('sugarss'), from: 'test/js/object/fixtures/index.sss', to: 'test/js/object/expect/index.sss' } return postcss(plugins) .process(fixture('index.sss'), options) .then(function (result) { t.is(expect('index.sss'), result.css) }) }) }) postcss-load-plugins-2.3.0/test/js/object/postcss.config.js000066400000000000000000000004131305020704600237420ustar00rootroot00000000000000module.exports = function (ctx) { return { plugins: { 'postcss-import': {}, 'postcss-nested': {}, 'postcss-sprites': {}, 'postcss-cssnext': { warnForDuplicates: false }, 'cssnano': ctx.env === 'production' ? {} : false } } } postcss-load-plugins-2.3.0/test/pkg/000077500000000000000000000000001305020704600173435ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/pkg/expect/000077500000000000000000000000001305020704600206335ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/pkg/expect/index.css000066400000000000000000000002441305020704600224540ustar00rootroot00000000000000.import { color: goldenrod; } .test { color: cyan; } .test__yellow { color: yellow; } .test__navy { color: navy; } .test__crimson { color: crimson; } postcss-load-plugins-2.3.0/test/pkg/expect/index.sss000066400000000000000000000002441305020704600224740ustar00rootroot00000000000000.import { color: goldenrod; } .test { color: cyan; } .test__yellow { color: yellow; } .test__navy { color: navy; } .test__crimson { color: crimson; } postcss-load-plugins-2.3.0/test/pkg/fixtures/000077500000000000000000000000001305020704600212145ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/pkg/fixtures/imports/000077500000000000000000000000001305020704600227115ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/pkg/fixtures/imports/section.css000066400000000000000000000000401305020704600250610ustar00rootroot00000000000000.import { color: goldenrod; } postcss-load-plugins-2.3.0/test/pkg/fixtures/imports/section.sss000066400000000000000000000000331305020704600251030ustar00rootroot00000000000000.import color: goldenrod postcss-load-plugins-2.3.0/test/pkg/fixtures/index.css000066400000000000000000000002511305020704600230330ustar00rootroot00000000000000@import 'imports/section.css'; .test { color: cyan; &__yellow { color: yellow; } &__navy { color: navy; } &__crimson { color: crimson; } } postcss-load-plugins-2.3.0/test/pkg/fixtures/index.sss000066400000000000000000000002161305020704600230540ustar00rootroot00000000000000@import 'imports/section.sss' .test color: cyan &__yellow color: yellow &__navy color: navy &__crimson color: crimson postcss-load-plugins-2.3.0/test/pkg/index.js000066400000000000000000000035011305020704600210070ustar00rootroot00000000000000// ------------------------------------- // # POSTCSS - LOAD PlUGINS - TEST - PKG // ------------------------------------- 'use strict' var test = require('ava') var path = require('path') var read = require('fs').readFileSync var postcss = require('postcss') var pluginsrc = require('../..') var fixture = function (file) { return read(path.join(__dirname, 'fixtures', file), 'utf8') } var expect = function (file) { return read(path.join(__dirname, 'expect', file), 'utf8') } test('package.json - {Object} - Load Plugins', function (t) { return pluginsrc({}, 'test/pkg').then(function (config) { var plugins = config.plugins t.is(plugins.length, 4) t.is(plugins[0].postcssPlugin, 'postcss-import') t.is(plugins[1].postcssPlugin, 'postcss-nested') t.is(plugins[2].postcssPlugin, 'postcss-sprites') t.is(plugins[3].postcssPlugin, 'postcss-cssnext') t.is(config.file, path.resolve('test/pkg/package.json')) }) }) test('package.json - {Object} - Process CSS', function (t) { return pluginsrc({}, 'test/pkg').then(function (config) { var plugins = config.plugins var options = { from: 'test/pkg/fixtures/index.css', to: 'test/pkg/expect/index.css' } return postcss(plugins) .process(fixture('index.css'), options) .then(function (result) { t.is(expect('index.css'), result.css) }) }) }) test('package.json - {Object} - Process SSS', function (t) { return pluginsrc({}, 'test/pkg').then(function (config) { var plugins = config.plugins var options = { parser: require('sugarss'), from: 'test/pkg/fixtures/index.sss', to: 'test/pkg/expect/index.sss' } return postcss(plugins) .process(fixture('index.sss'), options) .then(function (result) { t.is(expect('index.sss'), result.css) }) }) }) postcss-load-plugins-2.3.0/test/pkg/package.json000066400000000000000000000004051305020704600216300ustar00rootroot00000000000000{ "name": "postcss-config", "version": "1.0.0", "postcss": { "plugins": { "postcss-import": {}, "postcss-nested": {}, "postcss-sprites": {}, "postcss-cssnext": { "warnForDuplicates": false }, "cssnano": false } } } postcss-load-plugins-2.3.0/test/rc/000077500000000000000000000000001305020704600171665ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/rc/.postcssrc000066400000000000000000000002621305020704600212120ustar00rootroot00000000000000{ "plugins": { "postcss-import": {}, "postcss-nested": {}, "postcss-sprites": {}, "postcss-cssnext": { "warnForDuplicates": false }, "cssnano": false } } postcss-load-plugins-2.3.0/test/rc/expect/000077500000000000000000000000001305020704600204565ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/rc/expect/index.css000066400000000000000000000002441305020704600222770ustar00rootroot00000000000000.import { color: goldenrod; } .test { color: cyan; } .test__yellow { color: yellow; } .test__navy { color: navy; } .test__crimson { color: crimson; } postcss-load-plugins-2.3.0/test/rc/expect/index.sss000066400000000000000000000002441305020704600223170ustar00rootroot00000000000000.import { color: goldenrod; } .test { color: cyan; } .test__yellow { color: yellow; } .test__navy { color: navy; } .test__crimson { color: crimson; } postcss-load-plugins-2.3.0/test/rc/fixtures/000077500000000000000000000000001305020704600210375ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/rc/fixtures/imports/000077500000000000000000000000001305020704600225345ustar00rootroot00000000000000postcss-load-plugins-2.3.0/test/rc/fixtures/imports/section.css000066400000000000000000000000401305020704600247040ustar00rootroot00000000000000.import { color: goldenrod; } postcss-load-plugins-2.3.0/test/rc/fixtures/imports/section.sss000066400000000000000000000000331305020704600247260ustar00rootroot00000000000000.import color: goldenrod postcss-load-plugins-2.3.0/test/rc/fixtures/index.css000066400000000000000000000002511305020704600226560ustar00rootroot00000000000000@import 'imports/section.css'; .test { color: cyan; &__yellow { color: yellow; } &__navy { color: navy; } &__crimson { color: crimson; } } postcss-load-plugins-2.3.0/test/rc/fixtures/index.sss000066400000000000000000000002161305020704600226770ustar00rootroot00000000000000@import 'imports/section.sss' .test color: cyan &__yellow color: yellow &__navy color: navy &__crimson color: crimson postcss-load-plugins-2.3.0/test/rc/index.js000066400000000000000000000034561305020704600206430ustar00rootroot00000000000000// ------------------------------------ // # POSTCSS - LOAD PlUGINS - TEST - RC // ------------------------------------ 'use strict' var test = require('ava') var path = require('path') var read = require('fs').readFileSync var postcss = require('postcss') var pluginsrc = require('../..') var fixture = function (file) { return read(path.join(__dirname, 'fixtures', file), 'utf8') } var expect = function (file) { return read(path.join(__dirname, 'expect', file), 'utf8') } test('.postcssrc - {Object} - Load Plugins', function (t) { return pluginsrc({}, 'test/rc').then(function (config) { var plugins = config.plugins t.is(plugins.length, 4) t.is(plugins[0].postcssPlugin, 'postcss-import') t.is(plugins[1].postcssPlugin, 'postcss-nested') t.is(plugins[2].postcssPlugin, 'postcss-sprites') t.is(plugins[3].postcssPlugin, 'postcss-cssnext') t.is(config.file, path.resolve('test/rc/.postcssrc')) }) }) test('.postcssrc - {Object} - Process CSS', function (t) { return pluginsrc({}, 'test/rc').then(function (config) { var plugins = config.plugins var options = { from: 'test/rc/fixtures/index.css', to: 'test/rc/expect/index.css' } return postcss(plugins) .process(fixture('index.css'), options) .then(function (result) { t.is(expect('index.css'), result.css) }) }) }) test('.postcssrc - {Object} - Process SSS', function (t) { return pluginsrc({}, 'test/rc').then(function (config) { var plugins = config.plugins var options = { parser: require('sugarss'), from: 'test/rc/fixtures/index.sss', to: 'test/rc/expect/index.sss' } return postcss(plugins) .process(fixture('index.sss'), options) .then(function (result) { t.is(expect('index.sss'), result.css) }) }) })