first commit
This commit is contained in:
17
build/node_modules/postcss-message-helpers/CHANGELOG.md
generated
vendored
Executable file
17
build/node_modules/postcss-message-helpers/CHANGELOG.md
generated
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
# 2.0.0 - 2014-01-26
|
||||
|
||||
- Added: compatibility with postcss v4.x
|
||||
- Removed: compability with postcss v3.x
|
||||
|
||||
# 1.1.1 - 2014-11-24
|
||||
|
||||
- Fixed: issue with multilines error message in stack trace
|
||||
- Added: `originalMessage` property in the exception
|
||||
|
||||
# 1.1.0 - 2014-11-24
|
||||
|
||||
- Added: `try` now returns the result of the callback
|
||||
|
||||
# 1.0.0 - 2014-11-24
|
||||
|
||||
✨ First release
|
||||
20
build/node_modules/postcss-message-helpers/LICENSE
generated
vendored
Executable file
20
build/node_modules/postcss-message-helpers/LICENSE
generated
vendored
Executable file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Maxime Thirouin
|
||||
|
||||
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.
|
||||
80
build/node_modules/postcss-message-helpers/README.md
generated
vendored
Executable file
80
build/node_modules/postcss-message-helpers/README.md
generated
vendored
Executable file
@@ -0,0 +1,80 @@
|
||||
# postcss-message-helpers [](https://travis-ci.org/MoOx/postcss-message-helpers)
|
||||
|
||||
> [PostCSS](https://github.com/postcss/postcss) helpers to throw or output GNU style messages.
|
||||
|
||||
This 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`
|
||||
|
||||
## Installation
|
||||
|
||||
```console
|
||||
$ npm install postcss-message-helpers
|
||||
```
|
||||
|
||||
```js
|
||||
var messageHelpers = require("postcss-message-helpers")
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### `var fnValue = messageHelpers.try(fn, source)`
|
||||
|
||||
Execute `fn` an return the value.
|
||||
If an exception is thrown during the process, the exception will be catched, enhanced from source & re-throw.
|
||||
|
||||
### `var sourceMessage = messageHelpers.message(message, source)`
|
||||
|
||||
Returns a message like `sourcefile:lineno:column: message`.
|
||||
`source` should be a postcss source object from a node.
|
||||
|
||||
### `var source = messageHelpers.source(source)`
|
||||
|
||||
Returns `sourcefile:lineno:column` for a given `source` postcss object.
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
// dependencies
|
||||
var fs = require("fs")
|
||||
var postcss = require("postcss")
|
||||
var messageHelpers = require("postcss-message-helpers")
|
||||
|
||||
// css to be processed
|
||||
var css = fs.readFileSync("input.css", "utf8")
|
||||
|
||||
// process css
|
||||
var output = postcss()
|
||||
.use(function(styles) {
|
||||
styles.eachDecl(function transformDecl(decl) {
|
||||
// will catch, adjust error stack, line, column & message (gnu style) then re-throw
|
||||
messageHelpers.try(function IwillThrow() {
|
||||
if (decl.value.indexOf("error(") > -1) {
|
||||
throw new Error("error detected: " + decl.value)
|
||||
}
|
||||
}, decl.source)
|
||||
|
||||
// will output a gnu style warning
|
||||
if (decl.value.indexOf("warning(") > -1) {
|
||||
console.warning(messageHelpers.message("warning: " + decl.value, decl.source))
|
||||
}
|
||||
})
|
||||
})
|
||||
.process(css)
|
||||
.css
|
||||
```
|
||||
|
||||
Checkout [tests](test) for more examples.
|
||||
|
||||
---
|
||||
|
||||
## Contributing
|
||||
|
||||
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
|
||||
|
||||
$ git clone https://github.com/MoOx/postcss-message-helpers.git
|
||||
$ git checkout -b patch-1
|
||||
$ npm install
|
||||
$ npm test
|
||||
|
||||
## [Changelog](CHANGELOG.md)
|
||||
|
||||
## [License](LICENSE)
|
||||
81
build/node_modules/postcss-message-helpers/index.js
generated
vendored
Executable file
81
build/node_modules/postcss-message-helpers/index.js
generated
vendored
Executable file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
var SPLITTER = "\n at "
|
||||
|
||||
/**
|
||||
* PostCSS helpers
|
||||
*/
|
||||
module.exports = {
|
||||
sourceString: sourceString,
|
||||
message: formatMessage,
|
||||
try: tryCatch
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns GNU style source
|
||||
*
|
||||
* @param {Object} source
|
||||
*/
|
||||
function sourceString(source) {
|
||||
var message = "<css input>"
|
||||
if (source) {
|
||||
if (source.input && source.input.file) {
|
||||
message = source.input.file
|
||||
}
|
||||
if (source.start) {
|
||||
message += ":" + source.start.line + ":" + source.start.column
|
||||
}
|
||||
}
|
||||
|
||||
return message
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a GNU style message
|
||||
*
|
||||
* @param {String} message
|
||||
* @param {Object} source a PostCSS source object
|
||||
* @return {String}
|
||||
*/
|
||||
function formatMessage(message, source) {
|
||||
return sourceString(source) + ": " + message
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something and throw an error with enhanced exception (from given source)
|
||||
*
|
||||
* @param {Function} fn [description]
|
||||
* @param {[type]} source [description]
|
||||
*/
|
||||
function tryCatch(fn, source) {
|
||||
try {
|
||||
return fn()
|
||||
}
|
||||
catch (err) {
|
||||
err.originalMessage = err.message
|
||||
err.message = formatMessage(err.message, source)
|
||||
|
||||
// if source seems interesting, enhance error
|
||||
if (typeof source === "object") {
|
||||
// add a stack item if something interesting available
|
||||
if ((source.input && source.input.file) || source.start) {
|
||||
var stack = err.stack.split(SPLITTER)
|
||||
var firstStackItem = stack.shift()
|
||||
stack.unshift(sourceString(source))
|
||||
stack.unshift(firstStackItem)
|
||||
err.stack = stack.join(SPLITTER)
|
||||
}
|
||||
|
||||
if (source.input && source.input.file) {
|
||||
err.fileName = source.input.file
|
||||
}
|
||||
if (source.start) {
|
||||
err.lineNumber = source.start.line
|
||||
err.columnNumber = source.start.column
|
||||
}
|
||||
}
|
||||
|
||||
throw err
|
||||
}
|
||||
}
|
||||
68
build/node_modules/postcss-message-helpers/package.json
generated
vendored
Normal file
68
build/node_modules/postcss-message-helpers/package.json
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"postcss-message-helpers@2.0.0",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "postcss-message-helpers@2.0.0",
|
||||
"_id": "postcss-message-helpers@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-pPL0+rbk/gAvCu0ABHjN9S+bpg4=",
|
||||
"_location": "/postcss-message-helpers",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "postcss-message-helpers@2.0.0",
|
||||
"name": "postcss-message-helpers",
|
||||
"escapedName": "postcss-message-helpers",
|
||||
"rawSpec": "2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/postcss-calc"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/postcss-message-helpers/-/postcss-message-helpers-2.0.0.tgz",
|
||||
"_spec": "2.0.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Maxime Thirouin"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/MoOx/postcss-message-helpers/issues"
|
||||
},
|
||||
"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",
|
||||
"postcss",
|
||||
"postcss-plugins",
|
||||
"messages",
|
||||
"error",
|
||||
"warning"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "postcss-message-helpers",
|
||||
"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"
|
||||
}
|
||||
Reference in New Issue
Block a user