Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,70 @@
# 2.0.4
* Now compiled with Babel 6.
# 2.0.3
* Fixes an issue where comments that were removed from selectors were replaced
by a single space.
# 2.0.2
* Fixes an integration issue where comments inside values transformed by other
processors had their values reset to their original state before the
comments were removed.
# 2.0.1
* Replaces a dependency on node-balanced with internal comments parser.
# 2.0.0
* Upgraded to PostCSS 5 (thanks to @avanes).
# 1.2.1
* Improved performance by iterating the AST in a single pass.
# 1.2.0
* Adds support for user-directed removal of comments, with the `remove`
option (thanks to @dmitrykiselyov).
* `removeAllButFirst` now operates on each CSS tree, rather than the first one
passed to the plugin.
* Fixes to pass the PostCSS plugin guidelines.
# 1.1.3
* As PostCSS handles the source map content, there is no need to check for
the existence of a '#' at position 0 of the comment. This patch fixes this
behaviour.
# 1.1.2
* Fixes an issue where comment separated values were being incorrectly
transformed to not have spaces separating them instead, in `decl.value`.
e.g. `10px/*test*/20px` became `10px20px` in `decl.value` but not
`decl._value.raw`.
# 1.1.1
* Fixes a bug where non-special comments, with an exclamation mark in any part
of the text, were not being removed.
# 1.1.0
* Now uses the PostCSS `4.1` plugin API.
* Adds support for transforming comments inside `!important` values.
# 1.0.2
* Adds a JSHint config, tidy up unnecessary lines of code.
# 1.0.1
* Fixed a bug which affected initializing the plugin with no options.
* Stopped the plugin from trying to match comments in empty strings.
# 1.0.0
* Initial release.

View File

@@ -0,0 +1,22 @@
Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
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.

View File

@@ -0,0 +1,118 @@
# [postcss][postcss]-discard-comments [![Build Status](https://travis-ci.org/ben-eb/postcss-discard-comments.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-discard-comments.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-discard-comments.svg)][deps]
> Discard comments in your CSS files with PostCSS.
## Install
With [npm](https://npmjs.org/package/postcss-discard-comments) do:
```
npm install postcss-discard-comments --save
```
## Example
### Input
```css
h1/* heading */{
margin: 0 auto
}
```
### Output
```css
h1 {
margin: 0 auto
}
```
This module discards comments from your CSS files; by default, it will remove
all regular comments (`/* comment */`) and preserve comments marked as important
(`/*! important */`).
Note that this module does not handle source map comments because they are not
available to it; PostCSS handles this internally, so if they are removed then
you will have to [configure source maps in PostCSS][maps].
[maps]: https://github.com/postcss/postcss/blob/master/docs/source-maps.md
## API
### comments([options])
#### options
##### remove(function)
Type: `function`
Return: `boolean`
Variable: `comment` contains a comment without `/**/`
For each comment, return true to remove, or false to keep the comment.
```js
function(comment) {}
```
```js
var css = '/* headings *//*@ h1 */h1{margin:0 auto}/*@ h2 */h2{color:red}';
console.log(postcss(comments({
remove: function(comment) { return comment[0] == "@"; }
})).process(css).css);
//=> /* headings */h1{margin:0 auto}h2{color:red}
```
**NOTE:** If you use the `remove` function other options will not be available.
##### removeAll
Type: `boolean`
Default: `false`
Remove all comments marked as important.
```js
var css = '/*! heading */h1{margin:0 auto}/*! heading 2 */h2{color:red}';
console.log(postcss(comments({removeAll: true})).process(css).css);
//=> h1{margin:0 auto}h2{color:red}
```
##### removeAllButFirst
Type: `boolean`
Default: `false`
Remove all comments marked as important, but the first one.
```js
var css = '/*! heading */h1{margin:0 auto}/*! heading 2 */h2{color:red}';
console.log(postcss(comments({removeAllButFirst: true})).process(css).css);
//=> /*! heading */h1{margin:0 auto}h2{color:red}
```
## Usage
See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
examples for your environment.
## Contributing
Pull requests are welcome. If you add functionality, then please add unit tests
to cover it.
## License
MIT © Ben Briggs
[ci]: https://travis-ci.org/ben-eb/postcss-discard-comments
[deps]: https://gemnasium.com/ben-eb/postcss-discard-comments
[npm]: http://badge.fury.io/js/postcss-discard-comments
[postcss]: https://github.com/postcss/postcss

View File

@@ -0,0 +1,98 @@
'use strict';
exports.__esModule = true;
var _commentRemover = require('./lib/commentRemover');
var _commentRemover2 = _interopRequireDefault(_commentRemover);
var _commentParser = require('./lib/commentParser');
var _commentParser2 = _interopRequireDefault(_commentParser);
var _postcss = require('postcss');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var space = _postcss.list.space;
exports.default = (0, _postcss.plugin)('postcss-discard-comments', function () {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var remover = new _commentRemover2.default(opts);
function matchesComments(source) {
return (0, _commentParser2.default)(source).filter(function (node) {
return node.type === 'comment';
});
}
function replaceComments(source) {
var separator = arguments.length <= 1 || arguments[1] === undefined ? ' ' : arguments[1];
if (!source) {
return source;
}
var parsed = (0, _commentParser2.default)(source).reduce(function (value, node) {
if (node.type !== 'comment') {
return value + node.value;
}
if (remover.canRemove(node.value)) {
return value + separator;
}
return value + '/*' + node.value + '*/';
}, '');
return space(parsed).join(' ');
}
return function (css) {
css.walk(function (node) {
if (node.type === 'comment' && remover.canRemove(node.text)) {
node.remove();
return;
}
if (node.raws.between) {
node.raws.between = replaceComments(node.raws.between);
}
if (node.type === 'decl') {
if (node.raws.value && node.raws.value.raw) {
if (node.raws.value.value === node.value) {
node.value = replaceComments(node.raws.value.raw);
} else {
node.value = replaceComments(node.value);
}
node.raws.value = null;
}
if (node.raws.important) {
node.raws.important = replaceComments(node.raws.important);
var b = matchesComments(node.raws.important);
node.raws.important = b.length ? node.raws.important : '!important';
}
return;
}
if (node.type === 'rule' && node.raws.selector && node.raws.selector.raw) {
node.raws.selector.raw = replaceComments(node.raws.selector.raw, '');
return;
}
if (node.type === 'atrule') {
if (node.raws.afterName) {
var commentsReplaced = replaceComments(node.raws.afterName);
if (!commentsReplaced.length) {
node.raws.afterName = commentsReplaced + ' ';
} else {
node.raws.afterName = ' ' + commentsReplaced + ' ';
}
}
if (node.raws.params && node.raws.params.raw) {
node.raws.params.raw = replaceComments(node.raws.params.raw);
}
}
});
};
});
module.exports = exports['default'];

View File

@@ -0,0 +1,41 @@
'use strict';
exports.__esModule = true;
exports.default = commentParser;
function commentParser(input) {
var tokens = [];
var length = input.length;
var pos = 0;
var next = undefined;
while (pos < length) {
next = input.indexOf('/*', pos);
if (~next) {
tokens.push({
type: 'other',
value: input.slice(pos, next)
});
pos = next;
next = input.indexOf('*/', pos + 2);
if (! ~next) {
throw new Error('postcss-discard-comments: Unclosed */');
}
tokens.push({
type: 'comment',
value: input.slice(pos + 2, next)
});
pos = next + 2;
} else {
tokens.push({
type: 'other',
value: input.slice(pos)
});
pos = length;
}
}
return tokens;
};
module.exports = exports['default'];

View File

@@ -0,0 +1,28 @@
'use strict';
exports.__esModule = true;
function CommentRemover(options) {
this.options = options;
}
CommentRemover.prototype.canRemove = function (comment) {
var remove = this.options.remove;
if (remove) {
return remove(comment);
} else {
var isImportant = comment.indexOf('!') === 0;
if (!isImportant) {
return true;
} else if (isImportant) {
if (this.options.removeAll || this._hasFirst) {
return true;
} else if (this.options.removeAllButFirst && !this._hasFirst) {
this._hasFirst = true;
return false;
}
}
}
};
exports.default = CommentRemover;
module.exports = exports['default'];

View File

@@ -0,0 +1,86 @@
{
"_args": [
[
"postcss-discard-comments@2.0.4",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "postcss-discard-comments@2.0.4",
"_id": "postcss-discard-comments@2.0.4",
"_inBundle": false,
"_integrity": "sha1-vv6J+v1bPazlzM5Rt2uBUUvgDj0=",
"_location": "/css-loader/postcss-discard-comments",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "postcss-discard-comments@2.0.4",
"name": "postcss-discard-comments",
"escapedName": "postcss-discard-comments",
"rawSpec": "2.0.4",
"saveSpec": null,
"fetchSpec": "2.0.4"
},
"_requiredBy": [
"/css-loader/cssnano"
],
"_resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-2.0.4.tgz",
"_spec": "2.0.4",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Ben Briggs",
"email": "beneb.info@gmail.com",
"url": "http://beneb.info"
},
"ava": {
"require": "babel-core/register"
},
"bugs": {
"url": "https://github.com/ben-eb/postcss-discard-comments/issues"
},
"dependencies": {
"postcss": "^5.0.14"
},
"description": "Discard comments in your CSS files with PostCSS.",
"devDependencies": {
"ava": "^0.11.0",
"babel-cli": "^6.5.1",
"babel-core": "^6.5.1",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.5.0",
"del-cli": "^0.2.0",
"eslint": "^1.10.3",
"eslint-config-cssnano": "^1.0.0",
"postcss-scss": "^0.1.3",
"postcss-simple-vars": "^1.2.0"
},
"eslintConfig": {
"extends": "cssnano"
},
"files": [
"dist",
"LICENSE-MIT"
],
"homepage": "https://github.com/ben-eb/postcss-discard-comments",
"keywords": [
"css",
"comments",
"postcss",
"postcss-plugin"
],
"license": "MIT",
"main": "dist/index.js",
"name": "postcss-discard-comments",
"repository": {
"type": "git",
"url": "git+https://github.com/ben-eb/postcss-discard-comments.git"
},
"scripts": {
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"pretest": "eslint src",
"test": "ava src/__tests__"
},
"version": "2.0.4"
}