UNPKG

motion

Version:

motion - moving development forward

72 lines (71 loc) 4.61 kB
{ "_args": [ [ "postcss-message-helpers@https://registry.npmjs.org/postcss-message-helpers/-/postcss-message-helpers-2.0.0.tgz", "/Users/nw/flint/packages/flint" ] ], "_from": "postcss-message-helpers@>=2.0.0 <3.0.0", "_id": "postcss-message-helpers@2.0.0", "_inCache": true, "_location": "/postcss-message-helpers", "_phantomChildren": {}, "_requested": { "name": "postcss-message-helpers", "raw": "postcss-message-helpers@https://registry.npmjs.org/postcss-message-helpers/-/postcss-message-helpers-2.0.0.tgz", "rawSpec": "https://registry.npmjs.org/postcss-message-helpers/-/postcss-message-helpers-2.0.0.tgz", "scope": null, "spec": "https://registry.npmjs.org/postcss-message-helpers/-/postcss-message-helpers-2.0.0.tgz", "type": "remote" }, "_requiredBy": [ "/postcss-calc" ], "_resolved": "https://registry.npmjs.org/postcss-message-helpers/-/postcss-message-helpers-2.0.0.tgz", "_shasum": "a4f2f4fab6e4fe002f0aed000478cdf52f9ba60e", "_shrinkwrap": null, "_spec": "postcss-message-helpers@https://registry.npmjs.org/postcss-message-helpers/-/postcss-message-helpers-2.0.0.tgz", "_where": "/Users/nw/flint/packages/flint", "author": { "name": "Maxime Thirouin" }, "bugs": { "url": "https://github.com/MoOx/postcss-message-helpers/issues" }, "dependencies": {}, "description": "PostCSS helpers to throw or output GNU style messages", "devDependencies": { "jscs": "^1.6.2", "jshint": "^2.5.6", "postcss": "^4.0.2", "tape": "^3.0.0" }, "files": [ "CHANGELOG.md", "LICENSE", "index.js" ], "homepage": "https://github.com/MoOx/postcss-message-helpers#readme", "keywords": [ "css", "error", "messages", "postcss", "postcss-plugins", "warning" ], "license": "MIT", "name": "postcss-message-helpers", "optionalDependencies": {}, "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", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/MoOx/postcss-message-helpers.git" }, "scripts": { "lint": "jscs *.js **/*.js && jshint . --exclude-path .gitignore", "test": "npm run lint && tape test" }, "version": "2.0.0" }