{"name":"postcss-message-helpers","version":"1.1.0","description":"PostCSS helpers to throw or output GNU style messages","keywords":["css","postcss","postcss-plugins","messages","error","warning"],"author":{"name":"Maxime Thirouin"},"license":"MIT","repository":{"type":"git","url":"https://github.com/postcss/postcss-message-helpers.git"},"files":["CHANGELOG.md","LICENSE","index.js"],"devDependencies":{"jscs":"^1.6.2","jshint":"^2.5.6","postcss":"^3.0.0","tape":"^3.0.0"},"scripts":{"lint":"jscs *.js **/*.js && jshint . --exclude-path .gitignore","test":"npm run lint && tape test"},"gitHead":"acb523ad595323ce453ae5e1a97e1893ec758534","bugs":{"url":"https://github.com/postcss/postcss-message-helpers/issues"},"homepage":"https://github.com/postcss/postcss-message-helpers","_id":"postcss-message-helpers@1.1.0","_shasum":"689d4195b2348896ccbb4d0e4d006b1f18ee08d6","_from":".","_npmVersion":"2.1.6","_nodeVersion":"0.10.33","_npmUser":{"name":"moox","email":"m@moox.io"},"maintainers":[{"name":"moox","email":"m@moox.io"}],"dist":{"shasum":"689d4195b2348896ccbb4d0e4d006b1f18ee08d6","tarball":"http://registry-npm.ywwl.com/postcss-message-helpers/download/postcss-message-helpers-1.1.0.tgz","integrity":"sha512-9LQxYkaFfWQIEF0HXq1FCqDpv/sP37Z04YS+QEheNz/tnsM2XoMz9xs42oCvAh5Xf0ZXUIfH6RY0kswAZS5CIA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHV93D8MwTisT0zzwkTanoKcD4wuN1DCc3r1dh1MM7C7AiAuImK/sq1TkIbSqyb9vPxCbJYDlHl/+oTonE9lRSX8DQ=="}],"size":2718,"noattachment":false,"key":"/postcss-message-helpers/-/postcss-message-helpers-1.1.0.tgz"},"directories":{},"readme":"# postcss-message-helpers [![Build Status](https://travis-ci.org/MoOx/postcss-message-helpers.png)](https://travis-ci.org/MoOx/postcss-message-helpers)\n\n> [PostCSS](https://github.com/postcss/postcss) helpers to throw or output GNU style messages.\n\nThis modules offers you some function to throw or just output messages with [GNU style](https://www.gnu.org/prep/standards/html_node/Errors.html): `sourcefile:lineno:column: message`\n\n## Installation\n\n```console\n$ npm install postcss-message-helpers\n```\n\n```js\nvar messageHelpers = require(\"postcss-message-helpers\")\n```\n\n## Usage\n\n### `var fnValue = messageHelpers.try(fn, source)`\n\nExecute `fn` an return the value.\nIf an exception is thrown during the process, the exception will be catched, enhanced from source & re-throw.\n\n### `var sourceMessage = messageHelpers.message(message, source)`\n\nReturns a message like `sourcefile:lineno:column: message`.  \n`source` should be a postcss source object from a node.\n\n### `var source = messageHelpers.source(source)`\n\nReturns `sourcefile:lineno:column` for a given `source` postcss object.\n\n### Example\n\n```js\n// dependencies\nvar fs = require(\"fs\")\nvar postcss = require(\"postcss\")\nvar messageHelpers = require(\"postcss-message-helpers\")\n\n// css to be processed\nvar css = fs.readFileSync(\"input.css\", \"utf8\")\n\n// process css\nvar output = postcss()\n  .use(function(styles) {\n    styles.eachDecl(function transformDecl(decl) {\n      // will catch, adjust error stack, line, column & message (gnu style) then re-throw\n      messageHelpers.try(function IwillThrow() {\n        if (decl.value.indexOf(\"error(\") > -1) {\n          throw new Error(\"error detected: \" + decl.value)\n        }\n      }, decl.source)\n\n      // will output a gnu style warning\n      if (decl.value.indexOf(\"warning(\") > -1) {\n        console.warning(messageHelpers.message(\"warning: \" + decl.value, decl.source))\n      }\n    })\n  })\n  .process(css)\n  .css\n```\n\nCheckout [tests](test) for more examples.\n\n---\n\n## Contributing\n\nWork on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.\n\n    $ git clone https://github.com/MoOx/postcss-message-helpers.git\n    $ git checkout -b patch-1\n    $ npm install\n    $ npm test\n\n## [Changelog](CHANGELOG.md)\n\n## [License](LICENSE)\n","publish_time":1416857448115,"_cnpm_publish_time":1416857448115,"dist-tags":{"latest":"2.0.0"}}