diff options
Diffstat (limited to 'node_modules/postcss-load-options')
-rw-r--r-- | node_modules/postcss-load-options/CHANGELOG.md | 20 | ||||
-rw-r--r-- | node_modules/postcss-load-options/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/postcss-load-options/README.md | 203 | ||||
-rw-r--r-- | node_modules/postcss-load-options/index.js | 64 | ||||
-rw-r--r-- | node_modules/postcss-load-options/lib/options.js | 33 | ||||
-rw-r--r-- | node_modules/postcss-load-options/package.json | 83 |
6 files changed, 424 insertions, 0 deletions
diff --git a/node_modules/postcss-load-options/CHANGELOG.md b/node_modules/postcss-load-options/CHANGELOG.md new file mode 100644 index 0000000..805dd80 --- /dev/null +++ b/node_modules/postcss-load-options/CHANGELOG.md @@ -0,0 +1,20 @@ +<a name="1.2.0"></a> +# [1.2.0](https://github.com/michael-ciniawsky/postcss-load-options/compare/v1.1.0...v1.2.0) (2017-02-13) + + +### Features + +* **index:** allow file extensions for .postcssrc ([fc15720](https://github.com/michael-ciniawsky/postcss-load-options/commit/fc15720)) + + + +<a name="1.1.0"></a> +# [1.1.0](https://github.com/michael-ciniawsky/postcss-load-options/compare/v1.0.2...v1.1.0) (2017-01-07) + + +### Features + +* **index:** config file ([d8349b7](https://github.com/michael-ciniawsky/postcss-load-options/commit/d8349b7)) + + + diff --git a/node_modules/postcss-load-options/LICENSE b/node_modules/postcss-load-options/LICENSE new file mode 100644 index 0000000..66ba19a --- /dev/null +++ b/node_modules/postcss-load-options/LICENSE @@ -0,0 +1,21 @@ +License (MIT) + +Copyright (c) 2016 Michael Ciniawsky <michael.ciniawsky@gmail.com> + +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. diff --git a/node_modules/postcss-load-options/README.md b/node_modules/postcss-load-options/README.md new file mode 100644 index 0000000..83f4f15 --- /dev/null +++ b/node_modules/postcss-load-options/README.md @@ -0,0 +1,203 @@ +[![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] + +<div align="center"> + <img width="100" height="100" title="Load Options" + src="https://michael-ciniawsky.github.io/postcss-load-options/logo.svg" + <a href="https://github.com/postcss/postcss"> + <img width="110" height="110" title="PostCSS" src="http://postcss.github.io/postcss/logo.svg" hspace="10"> + </a> + <h1>Load Options</h1> +</div> + +<h2 align="center">Install</h2> + +```bash +npm i -D postcss-load-options +``` +<h2 align="center">Usage</h2> + +### `package.json` + +Create **`postcss`** section in your projects **`package.json`**. + +``` +App + |– client + |– public + | + |- package.json +``` + +```json +{ + "dependencies": { + "sugarss": "0.2.0" + }, + "postcss": { + "parser": "sugarss", + "map": false, + "from": "path/to/src/file.css", + "to": "path/to/dest/file.css" + } +} +``` + +### `.postcssrc` + +Create a **`.postcssrc`** file. + +``` +App + |– client + |– public + | + |- (.postcssrc|.postcssrc.json|.postcssrc.yaml) + |- package.json +``` + +**`JSON`** +```json +{ + "parser": "sugarss", + "map": false, + "from": "path/to/src/file.css", + "to": "path/to/dest/file.css" +} +``` + +**`YAML`** +```yaml +parser: sugarss +map: false +from: "/path/to/src.sss" +to: "/path/to/dest.css" +``` + +### `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 +``` + +```js +module.exports = (ctx) => { + return { + parser: ctx.sugar ? 'sugarss' : false, + map: ctx.env === 'development' ? ctx.map || false, + from: 'path/to/src/file.css', + to: 'path/to/dest/file.css' + } +} +``` + +<h2 align="center">Options</h2> + +**`parser`**: + +```js +'parser': 'sugarss' +``` + +**`syntax`**: + +```js +'syntax': 'postcss-scss' +``` +**`stringifier`**: + +```js +'stringifier': 'midas' +``` + +[**`map`**:](https://github.com/postcss/postcss/blob/master/docs/source-maps.md) + +```js +'map': 'inline' +``` + +**`from`**: + +```js +from: 'path/to/dest/file.css' +``` + +**`to`**: + +```js +to: 'path/to/dest/file.css' +``` + +### Context + +When using a function `(postcss.config.js)`, it is possible to pass context to `postcss-load-options`, which will be evaluated before loading your options. By default `ctx.env (process.env.NODE_ENV)` and `ctx.cwd (process.cwd())` are available. + +<h2 align="center">Example</h2> + +### <img width="80" height="80" src="https://worldvectorlogo.com/logos/nodejs-icon.svg"> + +```js +const { readFileSync } = require('fs') + +const postcss = require('postcss') +const optionsrc = require('postcss-load-options') + +const sss = readFileSync('index.sss', 'utf8') + +const ctx = { sugar: true, map: 'inline' } + +optionsrc(ctx).then((options) => { + postcss() + .process(sss, options) + .then(({ css }) => console.log(css)) +})) +``` + +<h2 align="center">Maintainers</h2> + +<table> + <tbody> + <tr> + <td align="center"> + <img width="150 height="150" + src="https://avatars.githubusercontent.com/u/5419992?v=3&s=150"> + <br /> + <a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a> + </td> + </tr> + <tbody> +</table> + + +[npm]: https://img.shields.io/npm/v/postcss-load-options.svg +[npm-url]: https://npmjs.com/package/postcss-load-options + +[node]: https://img.shields.io/node/v/postcss-load-options.svg +[node-url]: https://nodejs.org/ + +[deps]: https://david-dm.org/michael-ciniawsky/postcss-load-options.svg +[deps-url]: https://david-dm.org/michael-ciniawsky/postcss-load-options + +[tests]: http://img.shields.io/travis/michael-ciniawsky/postcss-load-options.svg +[tests-url]: https://travis-ci.org/michael-ciniawsky/postcss-load-options + +[cover]: https://coveralls.io/repos/github/michael-ciniawsky/postcss-load-options/badge.svg +[cover-url]: https://coveralls.io/github/michael-ciniawsky/postcss-load-options + +[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 diff --git a/node_modules/postcss-load-options/index.js b/node_modules/postcss-load-options/index.js new file mode 100644 index 0000000..df9e186 --- /dev/null +++ b/node_modules/postcss-load-options/index.js @@ -0,0 +1,64 @@ +// ------------------------------------ +// #POSTCSS - LOAD OPTIONS +// ------------------------------------ + +'use strict' + +var resolve = require('path').resolve + +var config = require('cosmiconfig') +var assign = require('object-assign') + +var loadOptions = require('./lib/options') + +/** + * @author Michael Ciniawsky (@michael-ciniawsky) <michael.ciniawsky@gmail.com> + * @description Autoload Options for PostCSS + * + * + * @module postcss-load-options + * @version 1.2.0 + * + * @requires cosmiconfig + * @requires object-assign + * @requires lib/options + * + * @method optionsrc + * + * @param {Object} ctx Context + * @param {String} path Directory + * @param {Object} options Options + * @return {Object} options PostCSS Options + */ +module.exports = function optionsrc (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) console.log('PostCSS Options could not be loaded') + + file = result ? result.filepath : '' + + return result ? result.config : {} + }) + .then(function (options) { + if (typeof options === 'function') options = options(ctx) + + if (typeof options === 'object') options = assign(options, ctx) + + return options + }) + .then(function (options) { + return { options: loadOptions(options), file: file } + }) + .catch(console.log) +} diff --git a/node_modules/postcss-load-options/lib/options.js b/node_modules/postcss-load-options/lib/options.js new file mode 100644 index 0000000..e8e9e81 --- /dev/null +++ b/node_modules/postcss-load-options/lib/options.js @@ -0,0 +1,33 @@ +// ------------------------------------ +// #POSTCSS - LOAD OPTIONS - OPTIONS +// ------------------------------------ + +'use strict' + +/** + * + * @method options + * + * @param {Object} options PostCSS Config + * + * @return {Object} options PostCSS Options + */ +module.exports = function options (options) { + if (options.parser && typeof options.parser === 'string') { + options.parser = require(options.parser) + } + + if (options.syntax && typeof options.syntax === 'string') { + options.syntax = require(options.syntax) + } + + if (options.stringifier && typeof options.stringifier === 'string') { + options.stringifier = require(options.stringifier) + } + + if (options.plugins) { + delete options.plugins + } + + return options +} diff --git a/node_modules/postcss-load-options/package.json b/node_modules/postcss-load-options/package.json new file mode 100644 index 0000000..db4757c --- /dev/null +++ b/node_modules/postcss-load-options/package.json @@ -0,0 +1,83 @@ +{ + "_args": [ + [ + "postcss-load-options@1.2.0", + "/home/dstaesse/git/website" + ] + ], + "_development": true, + "_from": "postcss-load-options@1.2.0", + "_id": "postcss-load-options@1.2.0", + "_inBundle": false, + "_integrity": "sha1-sJixVZ3awt8EvAuzdfmaXP4rbYw=", + "_location": "/postcss-load-options", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "postcss-load-options@1.2.0", + "name": "postcss-load-options", + "escapedName": "postcss-load-options", + "rawSpec": "1.2.0", + "saveSpec": null, + "fetchSpec": "1.2.0" + }, + "_requiredBy": [ + "/postcss-load-config" + ], + "_resolved": "https://registry.npmjs.org/postcss-load-options/-/postcss-load-options-1.2.0.tgz", + "_spec": "1.2.0", + "_where": "/home/dstaesse/git/website", + "author": { + "name": "Michael Ciniawky", + "email": "michael.ciniawsky@gmail.com" + }, + "bugs": { + "url": "https://github.com/michael-ciniawsky/postcss-load-options/issues" + }, + "dependencies": { + "cosmiconfig": "^2.1.0", + "object-assign": "^4.1.0" + }, + "description": "Autoload Options for PostCSS", + "devDependencies": { + "ava": "^0.18.1", + "coveralls": "^2.11.16", + "jsdoc-to-markdown": "^3.0.0", + "midas": "^2.0.3", + "nyc": "^10.1.0", + "postcss": "^5.2.12", + "postcss-scss": "^0.4.0", + "standard": "^8.6.0", + "standard-changelog": "0.0.1", + "sugarss": "^0.2.0" + }, + "engines": { + "node": ">=0.12" + }, + "files": [ + "lib", + "index.js" + ], + "homepage": "https://github.com/michael-ciniawsky/postcss-load-options#readme", + "keywords": [ + "postcss", + "postcss-options" + ], + "license": "MIT", + "main": "index.js", + "name": "postcss-load-options", + "repository": { + "type": "git", + "url": "git+https://github.com/michael-ciniawsky/postcss-load-options.git" + }, + "scripts": { + "clean": "rm -rf .nyc_output coverage jsdoc-api dmd", + "docs": "jsdoc2md index.js lib/options.js > INDEX.md", + "lint": "standard", + "logs": "standard-changelog -i CHANGELOG.md -w", + "start": "sudo npm run clean && npm run lint && sudo npm test", + "test": "nyc ava -v test/pkg/index.js test/rc/index.js test/js/index.js test/err/index.js" + }, + "version": "1.2.0" +} |