This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

453
node_modules/gonzales-pe/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,453 @@
# Changelog
#### Legend:
:japanese_ogre: — be afraid of this change because it breaks the way things
worked before.
:star: — some new thing has been added.
:green_apple: — some bad thing has been fixed.
## 21.04.2019, version 4.2.4
:star: Renamed `prepublish` script to `prepublishOnly`.
:star: Updated link to playground.
:green_apple: Fixed badges.
:green_apple: Fixed `content` guard in `node.contains()`.
## 28.09.2017, version 4.2.3
:green_apple: Fixed parsing of empty `url()` in Sass and SCSS.
## 30.08.2017, version 4.2.2
:green_apple: Fixed parsing of `/deep/` in CSS, LESS, Sass and SCSS.
## 29.08.2017, version 4.2.1
:green_apple: Fixed parsing of `pseudo-element` in CSS, LESS, Sass and SCSS.
## 29.08.2017, version 4.2.0
:star: Add support for custom property syntax in CSS, Sass and SCSS.
:star: Add support for deep combinator syntax in CSS, LESS, Sass and SCSS.
:star: Add support for alternative descendant `>>` syntax in CSS, LESS, Sass and SCSS.
:star: Add support for `::slotted()` syntax in CSS, LESS, Sass and SCSS.
:green_apple: Fixed parsing of non-lowercase keyframes at-rule in CSS, LESS, Sass and SCSS.
:green_apple: Fixed parsing of multiline selectors within keyframes in Sass.
:green_apple: Fixed parsing of `!important` within maps in Sass and SCSS.
:green_apple: Fixed parsing of `...` following a function in Sass and SCSS.
## 23.08.2017, version 4.1.1
:star: Unified codebase style across syntaxes.
:green_apple: Fixed parsing of URLs in Sass and SCSS.
:green_apple: Fixed parsing of placeholders in Sass and SCSS.
:green_apple: Fixed parsing of interpolated values within type selectors in Sass and SCSS.
:green_apple: Fixed parsing of spacing within pseudo class arguments in all syntaxes.
:green_apple: Fixed parsing of parent selectors within parentheses in Sass and SCSS.
:star: Abstracted attribute tests for CSS, LESS, Sass and SCSS.
:green_apple: Fixed parsing of pseudo classes within keyframes in Sass and SCSS.
:green_apple: Fixed parsing of dimensions in LESS.
## 20.11.2016, version 4.0.3
:green_apple: Fixed parsing of interpolations inside URI nodes in SCSS and Sass.
## 18.11.2016, version 4.0.2
:green_apple: Fixed parsing of trailing newlines.
## 18.11.2016, version 4.0.1
:japanese_ogre: Removed `postinstall` script.
## 17.11.2016, version 4.0.0
:japanese_ogre: Dropped support for Node < 4.
:japanese_ogre: Brought back `postinstall` script that should allow installing
from GitHub.
:japanese_ogre: Made multiline comments in Sass consistent with other syntaxes
by removing closing `*/` from node's content.
:japanese_ogre: Implemented new node type, `universalSelector`, which represents
`*`. See [docs](https://github.com/tonyganch/gonzales-pe/blob/dev/docs/node-types.md#universalselector)
for more details.
:green_apple: Fixed parsing of comments in Sass.
:green_apple: Fixed parsing of keyframes inside includes in Sass.
:green_apple: Fixed parsing of flags in arguments in Sass and SCSS.
:green_apple: Fixed parsing of multiple declarations within arguments in SCSS
and Sass.
:green_apple: Improved parsing of interpolations in SCSS and Sass.
:green_apple: Adjust parsing priority of declarations & atrule in Less.
## 22.10.2016, version 3.4.7
:green_apple: Included forgotten test for #226.
:green_apple: Fixed issue when `!important` was not parsed as function argument.
## 22.10.2016, version 3.4.6
:green_apple: Changed parsing of `ident` nodes which fixed issue with asterisks
being parsed as idents instead of operators.
:green_apple: Fixed capitalisation in Changelog.
## 20.10.2016, version 3.4.5
:green_apple: Change parser to strip DOS newlines from comments.
:star: Add links to README.md.
## 12.08.2016, version 3.4.4
:green_apple: Fixed parsing of numbers following interpolation in class
selectors in Sass and SCSS.
## 08.08.2016, version 3.4.3
:green_apple: Fixed parsing of unicode ranges.
## 04.08.2016, version 3.4.2
:green_apple: Disable Google Closure Compiler due to some errors in parsing.
## 27.07.2016, version 3.4.1
:star: Added publich script.
:green_apple: Fixed post-refactor error in Node#last method.
## 27.07.2016, version 3.4.0
:star: Added `unicode-range` and `urange` node types in CSS, Less, Sass and SCSS.
:green_apple: Fixed parsing of trailing interpolation in compound selector in Sass and SCSS.
:green_apple: Fix parsing of hyphens after interpolation with parentSelectors in Sass and SCSS.
:green_apple: Added ESLint and moved linters to a separate script.
:green_apple: Fixed incorrect dimension wrap of unicode-ranges in CSS, Sass and SCSS.
:green_apple: Fixed parsing of hyphens in interpolated idents in Sass and SCSS.
:green_apple: Added compilation of JS using Google Closure.
## 01.07.2016, version 3.3.6
:green_apple: Fixed parsing of nth selector without numbers before `n`.
## 21.06.2016, version 3.3.5
:green_apple: Fixed issue with content at-rule and keyframes in Sass and SCSS.
:green_apple: Fixed namespace attribute selector in CSS, Sass and SCSS.
:green_apple: Fixed issue with modulo operator in values in Sass.
:green_apple: Fixed usage of @content with keyframes in Sass and SCSS.
:green_apple: Fixed namespace attribute selector issue in CSS, Sass and SCSS.
:green_apple: Fixed parsing of interpolations in pseudo-classes in Sass and SCSS.
:green_apple: Fixed interpolated percentage keyframe selector issue in Sass and SCSS.
:green_apple: Updated Travis config to not include environment variables.
## 18.05.2016, version 3.3.4
:green_apple: Fixed mistake from `@3.3.2` version when parent selector was
"correctly" parsed as property instead of value.
## 18.05.2016, version 3.3.3
:green_apple: Fixed prepublish script to build lib.
## 18.05.2016, version 3.3.2
:star: Added AppVeyor badge.
:green_apple: Fixed build file to glue multiple syntaxes into one file.
:green_apple: Fixed parsing of functions inside urls in Sass.
:green_apple: Fixed parsing of mulitple keyframe selectors in CSS, Sass and SCSS.
:green_apple: Fixed parsing of parent selector as property in Sass and SCSS.
:green_apple: Fixed parsing of parent selector inside interpolations in Sass and SCSS.
## 29.04.2016, version 3.3.1
:star: Added config for AppVeyor to run automated tests on Windows.
:green_apple: Fix installation for Windows.
## 28.04.2016, version 3.3.0
:star: Added browser support. `build.sh` now build a script that can be used in
browsers.
## 28.04.2016, version 3.2.7
:green_apple: Fixed typos and example in documentation.
:green_apple: Fixed parsing of functions inside urls in SCSS.
:green_apple: Fixed parsing of selectors starting with combinators in Sass, SCSS
and Less.
:green_apple: Fixed incorrect CRLF line numbers.
:green_apple: Fixed parsing of extends that sometimes were incorrectly parsed
as atrules.
## 07.02.2016, version 3.2.6
:green_apple: Fixed the issue with installation of the package with npm@3.
## 07.02.2016, version 3.2.5
:green_apple: Fixed parsing of nested multiline selectors group.
## 07.02.2016, version 3.2.4
:star: Added support for `!global` in Sass.
## 07.02.2016, version 3.2.3
:star: Modified `npm test` to remove `.DS_Store` files before running tests.
:star: Updated Travis config to use Node@5.0.
:star: Updated Travis config to include compiler info.
:star: Made it possible to build files if module is installed from github.
:green_apple: Fixed parsing of interpolation content in Sass and SCSS.
:green_apple: Fixed parsing of interpolation as part of parent selector
extension in Sass and SCSS.
:green_apple: Fixed issue with keyframeSelector in includes in SCSS.
## 17.01.2016, version 3.2.2
:green_apple: Made `ParsingError#message` property writeable.
## 19.10.2015, version 3.2.1
#### Parsing rules
:green_apple: Fixed the issue when selectors inside extends were not wrapped in
`selector` nodes in Sass and SCSS.
:green_apple: Fixed parsing of multiple selectors in extends in Sass and SCSS.
## 19.10.2015, version 3.2.0
#### Node types
:star: Added new node type: `parentSelectorExtension`.
#### Parsing rules
:green_apple: Fixed parsing of parent selectors with extensions, like
`&__element` or `&--modifier`.
## 19.10.2015, version 3.1.1
#### Parsing rules
:green_apple: Fixed parsing of selectors starting or ending with a combinator
in Less, Sass and SCSS.
## 18.10.2015, version 3.1.0
#### CLI
:green_apple: Fixed passing a `--context` argument.
:green_apple: Fixed printing of a simplified tree.
#### Node types
:star: Added new node type: `keyframesSelector`.
#### Parsing rules
:green_apple: Fixed parsing of keyframes in all syntaxes.
## 18.10.2015, version 3.0.3
#### Parsing rules
:green_apple: Fixed parsing of spaces inside interpolations in Sass and SCSS.
## 18.10.2015, version 3.0.2
#### Parsing rules
:green_apple: Fixed the issue when operators were parsed as idents inside
parentheses in Sass and SCSS.
## 18.10.2015, version 3.0.1
#### Parsing rules
:green_apple: Fixed parsing of parent selectors in SCSS and Less.
:green_apple: Fixed parsing of placeholders inside selectors in SCSS.
## 18.10.2015, version 3.0.0
#### CLI
:japanese_ogre: Made cli process stdin only if `-` argument is passed.
:star: Added help message.
#### API
:japanese_ogre: Renamed `parseTree.remove` to `parseTree.removeChild()`.
:japanese_ogre: Unwraped callback parameters for `traverse...` methods.
:japanese_ogre: Made `first()`, `last()` and `get()` methods return `null` if no child nodes were found.
:japanese_ogre: Made `node.length` return a number of child nodes.
:japanese_ogre: Renamed `rule` to `context`.
:star: Made `parseTree.removeChild()` return a removed node.
:star: Added `traverseBy...` methods to all nodes, not only root ones.
:star: Added support for specifying a tab size in spaces.
#### Parsing rules
:green_apple: Fixed parsing of single-line comments after `url` token.
:green_apple: Fixed parsing of interpolations inside id selectors in Less.
:green_apple: Fixed parsing of selectors according to spec.
:green_apple: Fixed parsing of placeholders as selectors in SCSS.
#### Misc
:star: Added Travis badge to Readme page.
:star: Added init script to build sources.
:star: Added commit message template.
## 05.10.2015, version 3.0.0-beta
#### CLI
:star: Added `--simple` flag for printing a simplified tree structure.
:green_apple: CLI now prints parse tree to stdout.
#### API
:japanese_ogre: Parse tree is now represented as objects, not arrays.
:japanese_ogre: Renamed `gonzales.srcToAST()` to `gonzales.parse()`.
See [Readme](README.md#gonzalesparsecss-options).
:japanese_ogre: Renamed `gonzales.astToSrc()` to `parseTree.toString()`.
See [Readme](README.md#parsetreetostring).
:japanese_ogre: Renamed `gonzales.astToString()` to `parseTree.toJson()`.
See [Readme](README.md#parsetreetojson).
:star: Added information about column number to nodes.
:star: Added information about end position to nodes.
:green_apple: Made empty strings to be parsed as empty nodes.
#### Node types
:japanese_ogre: In Sass renamed `interpolatedVariable` to `interpolation`.
:japanese_ogre: Separated `include` and `extend` nodes.
:japanese_ogre: Replaced `filter` with `declaration`.
:japanese_ogre: Replaced `braces` with `brackets` and `parentheses`.
:japanese_ogre: Replaced `atrulers` with `block`.
:japanese_ogre: Renamed `nthSelector` to `pseudoClass`.
:japanese_ogre: Renamed `atrules`, `atruler` and `atruleb` to `atrule`.
:japanese_ogre: Renamed `functionBody` to `arguments`.
:japanese_ogre: Renamed `functionExpression` to `expression`.
:japanese_ogre: Renamed `attrib` to `attributeSelector`.
:japanese_ogre: Renamed `attrselector` to `attributeMatch`.
:japanese_ogre: Renamed `commentSL` to `singlelineComment`.
:japanese_ogre: Renamed `commentML` to `multilineComment`.
:japanese_ogre: Renamed `declDelim` to `declarationDelimiter`.
:japanese_ogre: Renamed `delim` to `delimiter`.
:japanese_ogre: Renamed `propertyDelim` to `propertyDelimiter`.
:japanese_ogre: Renamed `pseudoc` to `pseudoClass`.
:japanese_ogre: Renamed `pseudoe` to `pseudoElement`.
:japanese_ogre: Renamed `s` to `space`.
:japanese_ogre: Renamed `shash` to `color`.
:japanese_ogre: Renamed `vhash` to `id`.
:japanese_ogre: Removed `atrulerq`, `unary` and `unknown`.
:star: Added `attributeFlags`.
:star: Added `attributeName`.
:star: Added `attributeValue`.
:star: Added `conditionalStatement`.
:star: Added `namePrefix`.
:star: Added `namespacePrefix`.
:star: Added `namespaceSeparator`.
:star: Added `typeSelector`.
#### Parsing rules
:japanese_ogre: Spaces that separate two nodes are now put between those
nodes in parse tree.
:star: Added support for `extend` nodes in Less.
:star: Added support for equality and inequality signs in Sass and SCSS.
:star: Added support for `/deep/` combinator.
:star: Added support for `!optional` and `!global` in Sass and SCSS.
:green_apple: Fixed parsing of interpolations in Sass and SCSS.
:green_apple: Fixed parsing of arguments in Sass, SCSS and Less.
:green_apple: Fixed parsing of declaration delimiters in Sass.
:green_apple: Fixed the issue when pseudo-classes were parsed like declarations.
:green_apple: Fixed parsing of selectors on multiple lines in Sass.
:green_apple: Fixed parsing of percent sign as operator in SCSS.
:green_apple: Fixed parsing of pseudo-elements as selectors in Sass.
#### Misc
:star: Added Babel to build source files.
:star: Used mocha for tests.
:star: Added helper scripts.
:star: Added Travis config.
:rocket: Improved tests structure.
:rocket: Separated log and test scripts.
:rocket: Improved error messages.
:rocket: Removed benchmark tests.
:rocket: Moved source files from `lib` to `src` directory.
:rocket: Made package availbale for install from GitHub.
## 29.12.2013, version 2.0.2
- Sass includes can have both arguments list and content block,
i.e. `@include nani() { color: tomato }` is valid syntax.
## 18.11.2013, version 2.0.1
- Bring back lost whitespaces and comments
## 11.11.2013, version 2.0.0
- Support preprocessors: Sass (both SCSS and indented syntax), LESS.
- New node types:
- `arguments` (less and sass only)
- `commentML`
- `commentSL` (less and sass only)
- `condition` (sass only)
- `default` (sass only)
- `escapedString` (less only)
- `include` (less and sass only)
- `loop` (sass only)
- `mixin` (less and sass only)
- `parentselector` (less and sass only)
- `placeholder` (sass only)
- `propertyDelim`
- `variable` (less and sass only)
- `varialeList` (less and sass only)
- Rename methods:
- `srcToCSSP` -> `cssToAST`
- `csspToSrc` -> `astToCSS`
- `csspToTree` -> `astToTree`
- Pass all arguments as one object:
- `gonzales.cssToAST({css: a, syntax: b, rule: c, needInfo: d})`
- `gonzales.astToCSS({ast: ast, syntax: syntax})`
- Remove built files from VCS
- Move test command from `make` to `npm`
- Build files before running tests
- Divide tests into groups according to syntax
- Add script to test one specific css string
- Add token's index number to info object
## 11.02.2013, version 1.0.7
- Identifiers like `_0` are identifiers now.
- Throw error instead of console.error: https://github.com/css/csso/issues/109
## 25.11.2012, version 1.0.6
- Typo fix (global variable leak): https://github.com/css/csso/pull/110
- Attribute selectors extended by `|`.
- `not(..)` pseudo-class special support: https://github.com/css/csso/issues/111
## 28.10.2012, version 1.0.5
- Better error line numbering: https://github.com/css/gonzales/issues/2
## 11.10.2012, version 1.0.4
- CSSO issue (@page inside @media error): https://github.com/css/csso/issues/90
## 10.10.2012, version 1.0.3
- Both .t-1 and .t-01 should be idents: https://github.com/css/gonzales/issues/1
## 08.10.2012, version 1.0.2
- CSSO issue (filter + important breaks csso v1.3.1): https://github.com/css/csso/issues/87
## 08.10.2012, version 1.0.1
- CSSO issue ("filter" IE property breaks CSSO v1.3.0): https://github.com/css/csso/issues/86
## 03.10.2012, version 1.0.0
- First revision.

19
node_modules/gonzales-pe/MIT-LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (C) 2012 by Sergey Kryzhanovsky
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.

808
node_modules/gonzales-pe/README.md generated vendored Normal file
View File

@@ -0,0 +1,808 @@
# Gonzales PE @dev
[![NPM version][npm-img]][npm]
[![Build Status][travis-img]][travis]
[![AppVeyor Build Status][appveyor-img]][appveyor]
[npm-img]: https://img.shields.io/npm/v/gonzales-pe.svg
[npm]: https://www.npmjs.com/package/gonzales-pe
[travis-img]: https://travis-ci.org/tonyganch/gonzales-pe.svg
[travis]: https://travis-ci.org/tonyganch/gonzales-pe
[appveyor-img]: https://ci.appveyor.com/api/projects/status/m29jphtrqt398v2o/branch/dev?svg=true
[appveyor]: https://ci.appveyor.com/project/tonyganch/gonzales-pe/branch/dev
Gonzales PE is a CSS parser which plays nicely with preprocessors.
Currently those are supported: SCSS, Sass, LESS.
Try out Gonzales PE online: [Gonzales PE Playground](http://tonyganch.io/gonzales-pe/).
## Install
(1) To install command-line tool globally:
```bash
npm install -g git://github.com/tonyganch/gonzales-pe.git#dev
```
(2) To install parser as a project dependency:
```bash
npm install --save git://github.com/tonyganch/gonzales-pe.git#dev
```
(3) If for some reason you want to build files yourself:
```bash
# Clone the repo.
git clone git@github.com:tonyganch/gonzales-pe.git
# Go to dev branch.
git checkout dev
# Install project dependencies.
npm install
# Install git hooks and build files.
npm run init
```
## API
Basically there are a few things you can do:
1. parse css string and get a parse tree in return;
2. modify tree nodes;
3. remove tree nodes;
4. add new nodes to the tree;
5. convert modified tree back to a string.
The different type of tree nodes can be found in [docs/node-types.md](https://github.com/tonyganch/gonzales-pe/blob/dev/docs/node-types.md).
In examples below I assume that `gonzales` is a parser module and `parseTree`
is some parsed css:
```js
let gonzales = require('gonzales-pe');
let parseTree = gonzales.parse(css);
```
### gonzales.createNode(options)
##### Description
Creates a new node. Useful when you need to add something to a tree.
##### Parameters
<table>
<tr>
<td><i>{Object}</i></td>
<td>options</td>
<td>Options to pass to a `Node` constructor.</td>
</tr>
<tr>
</table>
##### Returns
<table>
<tr>
<td><i>{Object}</i></td>
<td>A new node.</td>
</tr>
</table>
##### Examples
```js
let css = 'a {color: tomato}';
let parseTree = gonzales.parse(css);
let node = gonzales.createNode({ type: 'animal', content: 'panda' });
parseTree.content.push(node);
```
### gonzales.parse(css[, options])
##### Description
Parses a css string.
##### Parameters
<table>
<tr>
<td><i>{string}</i></td>
<td>css</td>
<td>A string to parse.</td>
</tr>
<tr>
<td><i>{Object=}</i></td>
<td>options</td>
<td>Optional. Additional options:
<ul>
<li>
<code>{string} syntax</code> — any of the following: <code>css</code>,
<code>less</code>, <code>sass</code>, <code>scss</code>.
Default one is <code>css</code>.
</li>
<li>
<code>{string} context</code> — root node's type. For a list of available
values see <a href="docs/node-types.md">"Node types"</a>. Default
one is <code>stylesheet</code>.
</li>
<li>
<code>{number} tabSize</code> — size of a tab character in spaces.
Default one is 1.
</li>
</ul>
</td>
</tr>
</table>
##### Returns
<table>
<tr>
<td><i>{Object}</i></td>
<td>Parse tree.</td>
</tr>
</table>
##### Examples
```js
let css = 'a {color: tomato}';
let parseTree = gonzales.parse(css);
```
```js
let less = 'a {$color: tomato}';
let parseTree = gonzales.parse(less, {syntax: 'less'});
```
```js
let less = '$color: tomato';
let parseTree = gonzales.parse(less, {syntax: 'less', rule: 'declaration'});
```
### parseTree.contains(type)
##### Description
Checks whether there is a child node of given type.
##### Parameters
<table>
<tr>
<td><i>{string}</i></td>
<td>type</td>
<td>
Node type we're looking for. For a list of available values see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
</table>
##### Returns
<table>
<tr>
<td><i>{boolean}</i></td>
<td>
<code>true</code> if a tree contains a child node of a given type,
<code>false</code> otherwise.
</td>
</tr>
</table>
##### Examples
```js
if (parseTree.contains('space')) {
doSomething();
}
```
### parseTree.content
##### Returns
<table>
<tr>
<td><i>{string|Array}</i></td>
<td>Node's content (child nodes or a string).</td>
</tr>
</table>
### parseTree.eachFor([type, ]callback)
##### Description
Calls a function for every child node in tree. If `type` parameter is passed,
calls a function only for child nodes of a given type. The main difference from
`parseTree.forEach()` is that this method loops through node list from the end
to beginning.
##### Parameters
<table>
<tr>
<td><i>{string=}</i></td>
<td>type</td>
<td>
Optional. A node type by which to filter child nodes before applying
a callback function. For a list of available values see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
<tr>
<td><i>{Function}</i></td>
<td>callback</td>
<td>
Function to call for every child node. Accepts following parameters:
<ul>
<li><code>{Object}</code> — a child node;</li>
<li><code>{number}</code> — index of the child node in node list;</li>
<li>
<code>{Object}</code> — parent node (equals to <code>parseTree</code>).
</li>
</ul>
</td>
</tr>
</table>
##### Examples
```js
parseTree.eachFor(function(childNode) {
doSomething(childNode);
});
```
```js
// Remove all child spaces.
parseTree.eachFor('space', function(spaceNode, i) {
parseTree.removeChild(i);
});
```
### parseTree.end
##### Returns
<table>
<tr>
<td><i>{Object}</i></td>
<td>
End position of the node. Contains following info:
<ul>
<li>
<code>{number} line</code> — last symbol's line number
(1-based index);
</li>
<li>
<code>{number} column</code> — last symbol's column number
(1-based index).
</li>
</ul>
</td>
</tr>
</table>
### parseTree.first([type])
##### Description
Gets the first child node. If `type` parameter is passed, gets the first child
node of a given type. If no node has been found, returns `null`.
##### Parameters
<table>
<tr>
<td><i>{string=}</i></td>
<td>type</td>
<td>
Optional. Node type to look for. For a list of available values see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
</table>
##### Returns
<table>
<tr>
<td><i>{?Object}</i></td>
<td>A node.</td>
</tr>
</table>
##### Examples
```js
let node = parseTree.first();
node.content = 'panda';
```
```js
let node = parseTree.first('multilineComment');
node.content = 'panda';
```
### parseTree.forEach([type, ]callback)
##### Description
Calls a function for every child node in tree. If `type` parameter is passed,
calls a function only for child nodes of a given type. The main difference from
`parseTree.eachFor()` is that this method loops through node list from the
beginnig to end.
##### Parameters
<table>
<tr>
<td><i>{string=}</i></td>
<td>type</td>
<td>
Optional. A node type by which to filter child nodes before applying
a callback function. For a list of available values see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
<tr>
<td><i>{Function}</i></td>
<td>callback</td>
<td>
Function to call for every child node. Accepts following parameters:
<ul>
<li><code>{Object}</code> — a child node;</li>
<li><code>{number}</code> — index of the child node in node list;</li>
<li>
<code>{Object}</code> — parent node (equals to <code>parseTree</code>).
</li>
</ul>
</td>
</tr>
</table>
##### Examples
```js
parseTree.forEach(function(childNode) {
doSomething();
});
```
```js
parseTree.forEach('space', function(spaceNode) {
doSomething();
});
```
### parseTree.get(index)
##### Description
Gets *nth* child of the `parseTree`. If no node has been found, returns `null`.
##### Parameters
<table>
<tr>
<td><i>{number}</i></td>
<td>index</td>
<td>Index number of node which we're looking for.</td>
</tr>
</table>
##### Returns
<table>
<tr>
<td><i>{?Object}</i></td>
<td>A node.</td>
</tr>
</table>
##### Examples
```js
var node = parseTree.get(2);
doSomething(node);
```
### parseTree.insert(index, node)
##### Description
Inserts a node to a given position in `parseTree`.
##### Parameters
<table>
<tr>
<td><i>{number}</i></td>
<td>index</td>
<td>Index of position where to insert the node.</td>
</tr>
<tr>
<td><i>{Object}</i></td>
<td>node</td>
<td>A node to insert.</td>
</tr>
</table>
##### Examples
```js
let node = gonzales.createNode({type: 'animal', content: 'panda'});
parseTree.insert(2, node);
```
### parseTree.is(type)
##### Description
Checks whether the node is of given type.
##### Parameters
<table>
<tr>
<td><i>{string}</i></td>
<td>type</td>
<td>
A node type against which to check type of <code>parseTree</code>.
For a list of available values see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
</table>
##### Returns
<table>
<tr>
<td><i>{boolean}</i></td>
<td>
<code>true</code> if types are equal, <code>false</code> otherwise.
</td>
</tr>
</table>
##### Examples
```js
if (node.is('space')) {
node.content = '';
}
```
### parseTree.last(type)
Gets the last child node. If `type` parameter is passed, gets the last child
node of a given type. If no node has been found, returns `null`.
##### Parameters
<table>
<tr>
<td><i>{string=}</i></td>
<td>type</td>
<td>
Optional. Node type to look for. For a list of available values see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
</table>
##### Returns
<table>
<tr>
<td><i>{?Object}</i></td>
<td>A node.</td>
</tr>
</table>
##### Examples
```js
let node = parseTree.last();
node.content = 'panda';
```
```js
let node = parseTree.last('multilineComment');
node.content = 'panda';
```
### parseTree.length
##### Returns
<table>
<tr>
<td><i>{number}</i></td>
<td>Number of child nodes.</td>
</tr>
</table>
### parseTree.removeChild(index)
##### Description
Removes a child node at a given position.
##### Parameters
<table>
<tr>
<td><i>{number}</i></td>
<td>index</td>
<td>Index of a child node we need to remove.</td>
</tr>
</table>
##### Returns
<table>
<tr>
<td><i>{Object}</i></td>
<td>Removed node.</td>
</tr>
</table>
##### Examples
```js
// Swap nodes.
var node = parseTree.removeChild(1);
parseTree.insert(0, node);
```
### parseTree.start
##### Returns
<table>
<tr>
<td><i>{Object}</i></td>
<td>
Start position of the node. Contains following info:
<ul>
<li>
<code>{number} line</code> — first symbol's line number
(1-based index);
</li>
<li>
<code>{number} column</code> — first symbol's column number
(1-based index).
</li>
</ul>
</td>
</tr>
</table>
### parseTree.syntax
##### Returns
<table>
<tr>
<td><i>{string}</i></td>
<td>Syntax of original parsed string.</td>
</tr>
</table>
### parseTree.toJson()
##### Description
Converts parse tree to JSON. Useful for printing.
##### Returns
<table>
<tr>
<td><i>{Object}</i></td>
<td>Parse tree in JSON</td>
</tr>
</table>
### parseTree.toString()
##### Description
Converts parse tree back to string according to original syntax.
##### Returns
<table>
<tr>
<td><i>{string}</i></td>
<td>A compiled string.</td>
</tr>
</table>
##### Examples
```js
let css = parseTree.toString();
```
### parseTree.traverse(callback)
##### Description
Calls the function for every node in a tree including `parseTree` itself.
##### Parameters
<table>
<tr>
<td><i>{Function}</i></td>
<td>callback</td>
<td>
Function to apply to every node. Accepts following parameters:
<ul>
<li><code>{Object}</code> — a node to which we apply callback;</li>
<li><code>{number}</code> — node's index number inside its parent;</li>
<li><code>{Object}</code> — a node's parent;</li>
<li>
<code>{number}</code> — node's nesting level relative to its parent.
</li>
</ul>
</td>
</tr>
</table>
##### Examples
```js
parseTree.traverse(function(node, index, parent) {
if (node.is('multilineComment')) {
parent.removeChild(index);
} else if (node.is('space')) {
node.content = ' ';
}
});
```
### parseTree.traverseByType(type, callback)
##### Description
This method should be called for a root node, because calling it for a child
will be more time consuming.
Calls the function for every node of a given type. This means not just child
nodes, but grandchilds and so on.
##### Parameters
<table>
<tr>
<td><i>{string}</i></td>
<td>type</td>
<td>
Node type. For a list of available values please see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
<tr>
<td><i>{Function}</i></td>
<td>callback</td>
<td>
Function to apply to every node of a given type.
Accepts following parameters:
<ul>
<li><code>{Object}</code> — a node to which we apply callback;</li>
<li><code>{number}</code> — node's index number inside its parent;</li>
<li><code>{Object}</code> — a node's parent.</li>
</ul>
</td>
</tr>
</table>
##### Examples
```js
// Remove all comments.
parseTree.traverseByType('multilineComment', function(node, index, parent) {
parent.removeChild(index);
});
```
### parseTree.traverseByTypes(types, callback)
##### Description
This method should be called for a root node, because calling it for a child
will be more time consuming.
Calls the function for every node of given types. This means not just child
nodes, but grandchilds and so on.
##### Parameters
<table>
<tr>
<td><i>{Array.string}</i></td>
<td>types</td>
<td>
List of node types. For a list of available values please see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
<tr>
<td><i>{Function}</i></td>
<td>callback</td>
<td>
Function to apply to every node of given types.
Accepts following parameters:
<ul>
<li><code>{Object}</code> — a node to which we apply callback;</li>
<li><code>{number}</code> — node's index number inside its parent;</li>
<li><code>{Object}</code> — a node's parent.</li>
</ul>
</td>
</tr>
</table>
##### Examples
```js
// Remove all comments and spaces.
let types = ['multilineComment', 'space'];
parseTree.traverseByTypes(types, function(node, index, parent) {
parent.removeChild(index);
});
```
### parseTree.type
##### Returns
<table>
<tr>
<td><i>{string}</i></td>
<td>
Node type. For a list of available values see
<a href="docs/node-types.md">"Node types"</a>.
</td>
</tr>
</table>
## Test
To run tests:
npm test
This command will build library files from sources and run tests on all files
in syntax directories.
Every test has 3 files: source stylesheet, expected parse tree and expected
string compiled back from parse tree to css.
If some tests fail, you can find information in test logs:
- `log/test.log` contains all information from stdout;
- `log/expected.txt` contains only expected text;
- `log/result.txt` contains only result text.
The last two are made for your convenience: you can use any diff app to see
the defference between them.
If you want to test one specific string or get a general idea of how Gonzales
works, you can use `test/ast.js` file.
Simply change the first two strings (`css` and `syntax` vars) and run:
node test/single-test.js
## Report
If you find a bug or want to add a feature, welcome to [Issues](https://github.com/tonyganch/gonzales-pe/issues).
If you are shy but have a question, feel free to [drop me a
line](mailto:tonyganch+gonzales@gmail.com).

116
node_modules/gonzales-pe/bin/gonzales.js generated vendored Executable file
View File

@@ -0,0 +1,116 @@
#!/usr/bin/env node
'use strict';
var parseArgs = require('minimist');
var gonzales = require('..');
var fs = require('fs');
var path = require('path');
var options = getOptions();
if (options.help) {
displayHelp();
process.exit(0);
}
if (isSTDIN()) {
processSTDIN();
} else {
processFile(options._[0]);
}
function getOptions() {
var parserOptions = {
boolean: ['silent', 'simple'],
alias: {
help: 'h',
syntax: 's',
context: 'c'
}
};
return parseArgs(process.argv.slice(2), parserOptions);
}
function isSTDIN() {
return options._.indexOf('-') !== -1;
}
function processSTDIN() {
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', data => {
input += data;
});
process.stdin.on('end', () => {
processInputData(input);
});
}
function processFile(file) {
if (!file) process.exit(0);
if (!options.syntax) options.syntax = path.extname(file).substring(1);
var css = fs.readFileSync(file, 'utf-8').trim();
processInputData(css);
}
function processInputData(input) {
try {
var ast = gonzales.parse(input, {
syntax: options.syntax,
context: options.context
});
printTree(ast);
process.exit(0);
} catch (e) {
if (!options.silent) process.stderr.write(e.toString());
process.exit(1);
}
}
function printTree(ast) {
if (!options.simple) {
var tree = ast.toJson();
process.stdout.write(tree);
} else {
var lastLevel;
ast.traverse(function(node, i, parent, lastLevel) {
var type = node.type;
var spaces = new Array(lastLevel).join(' |');
if (typeof node.content === 'string') {
var content = JSON.stringify(node.content);
console.log(spaces, '->', type);
console.log(spaces, ' ', content);
} else {
console.log(spaces, '->', type);
}
});
var spaces = new Array(lastLevel).join(' -');
console.log(spaces);
}
}
function displayHelp() {
var help = [
'NAME',
' gonzlaes-pe — Parse a css file and print its parse tree in JSON',
'',
'SYNOPSIS',
' gonzales-pe [options] file.js',
' cat file.js | gonzales-pe [options] -',
'',
'OPTIONS',
' -s, --syntax',
' Syntax name: css, less, sass or scss.',
' -c, --context',
' Context of code part. See docs on node types for more info.',
' --simple',
' Print a simplified parse tree structure instead of JSON.',
' --silent',
' Don\'t print any error messages.'
];
console.log(help.join('\n'));
}

22435
node_modules/gonzales-pe/lib/gonzales.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "iojs"
before_install:
- npm install -g npm@~1.4.6

18
node_modules/gonzales-pe/node_modules/minimist/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,18 @@
This software is released under the MIT license:
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,2 @@
var argv = require('../')(process.argv.slice(2));
console.dir(argv);

230
node_modules/gonzales-pe/node_modules/minimist/index.js generated vendored Normal file
View File

@@ -0,0 +1,230 @@
module.exports = function (args, opts) {
if (!opts) opts = {};
var flags = { bools : {}, strings : {}, unknownFn: null };
if (typeof opts['unknown'] === 'function') {
flags.unknownFn = opts['unknown'];
}
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
flags.allBools = true;
} else {
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
flags.bools[key] = true;
});
}
var aliases = {};
Object.keys(opts.alias || {}).forEach(function (key) {
aliases[key] = [].concat(opts.alias[key]);
aliases[key].forEach(function (x) {
aliases[x] = [key].concat(aliases[key].filter(function (y) {
return x !== y;
}));
});
});
[].concat(opts.string).filter(Boolean).forEach(function (key) {
flags.strings[key] = true;
if (aliases[key]) {
flags.strings[aliases[key]] = true;
}
});
var defaults = opts['default'] || {};
var argv = { _ : [] };
Object.keys(flags.bools).forEach(function (key) {
setArg(key, defaults[key] === undefined ? false : defaults[key]);
});
var notFlags = [];
if (args.indexOf('--') !== -1) {
notFlags = args.slice(args.indexOf('--')+1);
args = args.slice(0, args.indexOf('--'));
}
function argDefined(key, arg) {
return (flags.allBools && /^--[^=]+$/.test(arg)) ||
flags.strings[key] || flags.bools[key] || aliases[key];
}
function setArg (key, val, arg) {
if (arg && flags.unknownFn && !argDefined(key, arg)) {
if (flags.unknownFn(arg) === false) return;
}
var value = !flags.strings[key] && isNumber(val)
? Number(val) : val
;
setKey(argv, key.split('.'), value);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), value);
});
}
function setKey (obj, keys, value) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
if (o[key] === undefined) o[key] = {};
o = o[key];
});
var key = keys[keys.length - 1];
if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
o[key] = value;
}
else if (Array.isArray(o[key])) {
o[key].push(value);
}
else {
o[key] = [ o[key], value ];
}
}
function aliasIsBoolean(key) {
return aliases[key].some(function (x) {
return flags.bools[x];
});
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (/^--.+=/.test(arg)) {
// Using [\s\S] instead of . because js doesn't support the
// 'dotall' regex modifier. See:
// http://stackoverflow.com/a/1068308/13216
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
var key = m[1];
var value = m[2];
if (flags.bools[key]) {
value = value !== 'false';
}
setArg(key, value, arg);
}
else if (/^--no-.+/.test(arg)) {
var key = arg.match(/^--no-(.+)/)[1];
setArg(key, false, arg);
}
else if (/^--.+/.test(arg)) {
var key = arg.match(/^--(.+)/)[1];
var next = args[i + 1];
if (next !== undefined && !/^-/.test(next)
&& !flags.bools[key]
&& !flags.allBools
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, next, arg);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
else if (/^-[^-]+/.test(arg)) {
var letters = arg.slice(1,-1).split('');
var broken = false;
for (var j = 0; j < letters.length; j++) {
var next = arg.slice(j+2);
if (next === '-') {
setArg(letters[j], next, arg)
continue;
}
if (/[A-Za-z]/.test(letters[j])
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next, arg);
broken = true;
break;
}
if (letters[j+1] && letters[j+1].match(/\W/)) {
setArg(letters[j], arg.slice(j+2), arg);
broken = true;
break;
}
else {
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
}
}
var key = arg.slice(-1)[0];
if (!broken && key !== '-') {
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
&& !flags.bools[key]
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, args[i+1], arg);
i++;
}
else if (args[i+1] && /true|false/.test(args[i+1])) {
setArg(key, args[i+1] === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
}
else {
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
argv._.push(
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
);
}
if (opts.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
break;
}
}
}
Object.keys(defaults).forEach(function (key) {
if (!hasKey(argv, key.split('.'))) {
setKey(argv, key.split('.'), defaults[key]);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), defaults[key]);
});
}
});
if (opts['--']) {
argv['--'] = new Array();
notFlags.forEach(function(key) {
argv['--'].push(key);
});
}
else {
notFlags.forEach(function(key) {
argv._.push(key);
});
}
return argv;
};
function hasKey (obj, keys) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
o = (o[key] || {});
});
var key = keys[keys.length - 1];
return key in o;
}
function isNumber (x) {
if (typeof x === 'number') return true;
if (/^0x[0-9a-f]+$/i.test(x)) return true;
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}

View File

@@ -0,0 +1,76 @@
{
"_args": [
[
"minimist@1.1.3",
"/Users/tatiana/selfdefined"
]
],
"_from": "minimist@1.1.3",
"_id": "minimist@1.1.3",
"_inBundle": false,
"_integrity": "sha1-O+39kaktOQFvz6ocaB6Pqhoe/ag=",
"_location": "/gonzales-pe/minimist",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "minimist@1.1.3",
"name": "minimist",
"escapedName": "minimist",
"rawSpec": "1.1.3",
"saveSpec": null,
"fetchSpec": "1.1.3"
},
"_requiredBy": [
"/gonzales-pe"
],
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.1.3.tgz",
"_spec": "1.1.3",
"_where": "/Users/tatiana/selfdefined",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"bugs": {
"url": "https://github.com/substack/minimist/issues"
},
"description": "parse argument options",
"devDependencies": {
"covert": "^1.0.0",
"tap": "~0.4.0",
"tape": "^3.5.0"
},
"homepage": "https://github.com/substack/minimist",
"keywords": [
"argv",
"getopt",
"parser",
"optimist"
],
"license": "MIT",
"main": "index.js",
"name": "minimist",
"repository": {
"type": "git",
"url": "git://github.com/substack/minimist.git"
},
"scripts": {
"coverage": "covert test/*.js",
"test": "tap test/*.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/6..latest",
"ff/5",
"firefox/latest",
"chrome/10",
"chrome/latest",
"safari/5.1",
"safari/latest",
"opera/12"
]
},
"version": "1.1.3"
}

View File

@@ -0,0 +1,91 @@
# minimist
parse argument options
This module is the guts of optimist's argument parser without all the
fanciful decoration.
[![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist)
[![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist)
# example
``` js
var argv = require('minimist')(process.argv.slice(2));
console.dir(argv);
```
```
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
```
```
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
x: 3,
y: 4,
n: 5,
a: true,
b: true,
c: true,
beep: 'boop' }
```
# methods
``` js
var parseArgs = require('minimist')
```
## var argv = parseArgs(args, opts={})
Return an argument object `argv` populated with the array arguments from `args`.
`argv._` contains all the arguments that didn't have an option associated with
them.
Numeric-looking arguments will be returned as numbers unless `opts.string` or
`opts.boolean` is set for that argument name.
Any arguments after `'--'` will not be parsed and will end up in `argv._`.
options can be:
* `opts.string` - a string or array of strings argument names to always treat as
strings
* `opts.boolean` - a boolean, string or array of strings to always treat as
booleans. if `true` will treat all double hyphenated arguments without equal signs
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
* `opts.alias` - an object mapping string names to strings or arrays of string
argument names to use as aliases
* `opts.default` - an object mapping string argument names to default values
* `opts.stopEarly` - when true, populate `argv._` with everything after the
first non-option
* `opts['--']` - when true, populate `argv._` with everything before the `--`
and `argv['--']` with everything after the `--`. Here's an example:
* `opts.unknown` - a function which is invoked with a command line parameter not
defined in the `opts` configuration object. If the function returns `false`, the
unknown option is not added to `argv`.
```
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
{ _: [ 'one', 'two', 'three' ],
'--': [ 'four', 'five', '--six' ] }
```
Note that with `opts['--']` set, parsing for arguments still stops after the
`--`.
# install
With [npm](https://npmjs.org) do:
```
npm install minimist
```
# license
MIT

View File

@@ -0,0 +1,32 @@
var parse = require('../');
var test = require('tape');
test('flag boolean true (default all --args to boolean)', function (t) {
var argv = parse(['moo', '--honk', 'cow'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});
test('flag boolean true only affects double hyphen arguments without equals signs', function (t) {
var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
tacos: 'good',
p: 55,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});

View File

@@ -0,0 +1,166 @@
var parse = require('../');
var test = require('tape');
test('flag boolean default false', function (t) {
var argv = parse(['moo'], {
boolean: ['t', 'verbose'],
default: { verbose: false, t: false }
});
t.deepEqual(argv, {
verbose: false,
t: false,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('boolean groups', function (t) {
var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], {
boolean: ['x','y','z']
});
t.deepEqual(argv, {
x : true,
y : false,
z : true,
_ : [ 'one', 'two', 'three' ]
});
t.deepEqual(typeof argv.x, 'boolean');
t.deepEqual(typeof argv.y, 'boolean');
t.deepEqual(typeof argv.z, 'boolean');
t.end();
});
test('boolean and alias with chainable api', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
herp: { alias: 'h', boolean: true }
};
var aliasedArgv = parse(aliased, {
boolean: 'herp',
alias: { h: 'herp' }
});
var propertyArgv = parse(regular, {
boolean: 'herp',
alias: { h: 'herp' }
});
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
alias: { 'h': 'herp' },
boolean: 'herp'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias array with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var alt = [ '--harp', 'derp' ];
var opts = {
alias: { 'h': ['herp', 'harp'] },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var altPropertyArgv = parse(alt, opts);
var expected = {
harp: true,
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.same(altPropertyArgv, expected);
t.end();
});
test('boolean and alias using explicit true', function (t) {
var aliased = [ '-h', 'true' ];
var regular = [ '--herp', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
// regression, see https://github.com/substack/node-optimist/issues/71
test('boolean and --x=true', function(t) {
var parsed = parse(['--boool', '--other=true'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'true');
parsed = parse(['--boool', '--other=false'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'false');
t.end();
});
test('boolean --boool=true', function (t) {
var parsed = parse(['--boool=true'], {
default: {
boool: false
},
boolean: ['boool']
});
t.same(parsed.boool, true);
t.end();
});
test('boolean --boool=false', function (t) {
var parsed = parse(['--boool=false'], {
default: {
boool: true
},
boolean: ['boool']
});
t.same(parsed.boool, false);
t.end();
});

View File

@@ -0,0 +1,31 @@
var parse = require('../');
var test = require('tape');
test('-', function (t) {
t.plan(5);
t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] });
t.deepEqual(parse([ '-' ]), { _: [ '-' ] });
t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] });
t.deepEqual(
parse([ '-b', '-' ], { boolean: 'b' }),
{ b: true, _: [ '-' ] }
);
t.deepEqual(
parse([ '-s', '-' ], { string: 's' }),
{ s: '-', _: [] }
);
});
test('-a -- b', function (t) {
t.plan(3);
t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] });
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
});
test('move arguments after the -- into their own `--` array', function(t) {
t.plan(1);
t.deepEqual(
parse([ '--name', 'John', 'before', '--', 'after' ], { '--': true }),
{ name: 'John', _: [ 'before' ], '--': [ 'after' ] });
});

View File

@@ -0,0 +1,35 @@
var test = require('tape');
var parse = require('../');
test('boolean default true', function (t) {
var argv = parse([], {
boolean: 'sometrue',
default: { sometrue: true }
});
t.equal(argv.sometrue, true);
t.end();
});
test('boolean default false', function (t) {
var argv = parse([], {
boolean: 'somefalse',
default: { somefalse: false }
});
t.equal(argv.somefalse, false);
t.end();
});
test('boolean default to null', function (t) {
var argv = parse([], {
boolean: 'maybe',
default: { maybe: null }
});
t.equal(argv.maybe, null);
var argv = parse(['--maybe'], {
boolean: 'maybe',
default: { maybe: null }
});
t.equal(argv.maybe, true);
t.end();
})

View File

@@ -0,0 +1,22 @@
var parse = require('../');
var test = require('tape');
test('dotted alias', function (t) {
var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
t.equal(argv.a.b, 22);
t.equal(argv.aa.bb, 22);
t.end();
});
test('dotted default', function (t) {
var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
t.equal(argv.a.b, 11);
t.equal(argv.aa.bb, 11);
t.end();
});
test('dotted default with no alias', function (t) {
var argv = parse('', {default: {'a.b': 11}});
t.equal(argv.a.b, 11);
t.end();
});

View File

@@ -0,0 +1,31 @@
var test = require('tape');
var parse = require('../');
test('long opts', function (t) {
t.deepEqual(
parse([ '--bool' ]),
{ bool : true, _ : [] },
'long boolean'
);
t.deepEqual(
parse([ '--pow', 'xixxle' ]),
{ pow : 'xixxle', _ : [] },
'long capture sp'
);
t.deepEqual(
parse([ '--pow=xixxle' ]),
{ pow : 'xixxle', _ : [] },
'long capture eq'
);
t.deepEqual(
parse([ '--host', 'localhost', '--port', '555' ]),
{ host : 'localhost', port : 555, _ : [] },
'long captures sp'
);
t.deepEqual(
parse([ '--host=localhost', '--port=555' ]),
{ host : 'localhost', port : 555, _ : [] },
'long captures eq'
);
t.end();
});

View File

@@ -0,0 +1,36 @@
var parse = require('../');
var test = require('tape');
test('nums', function (t) {
var argv = parse([
'-x', '1234',
'-y', '5.67',
'-z', '1e7',
'-w', '10f',
'--hex', '0xdeadbeef',
'789'
]);
t.deepEqual(argv, {
x : 1234,
y : 5.67,
z : 1e7,
w : '10f',
hex : 0xdeadbeef,
_ : [ 789 ]
});
t.deepEqual(typeof argv.x, 'number');
t.deepEqual(typeof argv.y, 'number');
t.deepEqual(typeof argv.z, 'number');
t.deepEqual(typeof argv.w, 'string');
t.deepEqual(typeof argv.hex, 'number');
t.deepEqual(typeof argv._[0], 'number');
t.end();
});
test('already a number', function (t) {
var argv = parse([ '-x', 1234, 789 ]);
t.deepEqual(argv, { x : 1234, _ : [ 789 ] });
t.deepEqual(typeof argv.x, 'number');
t.deepEqual(typeof argv._[0], 'number');
t.end();
});

View File

@@ -0,0 +1,197 @@
var parse = require('../');
var test = require('tape');
test('parse args', function (t) {
t.deepEqual(
parse([ '--no-moo' ]),
{ moo : false, _ : [] },
'no'
);
t.deepEqual(
parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]),
{ v : ['a','b','c'], _ : [] },
'multi'
);
t.end();
});
test('comprehensive', function (t) {
t.deepEqual(
parse([
'--name=meowmers', 'bare', '-cats', 'woo',
'-h', 'awesome', '--multi=quux',
'--key', 'value',
'-b', '--bool', '--no-meep', '--multi=baz',
'--', '--not-a-flag', 'eek'
]),
{
c : true,
a : true,
t : true,
s : 'woo',
h : 'awesome',
b : true,
bool : true,
key : 'value',
multi : [ 'quux', 'baz' ],
meep : false,
name : 'meowmers',
_ : [ 'bare', '--not-a-flag', 'eek' ]
}
);
t.end();
});
test('flag boolean', function (t) {
var argv = parse([ '-t', 'moo' ], { boolean: 't' });
t.deepEqual(argv, { t : true, _ : [ 'moo' ] });
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('flag boolean value', function (t) {
var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], {
boolean: [ 't', 'verbose' ],
default: { verbose: true }
});
t.deepEqual(argv, {
verbose: false,
t: true,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('newlines in params' , function (t) {
var args = parse([ '-s', "X\nX" ])
t.deepEqual(args, { _ : [], s : "X\nX" });
// reproduce in bash:
// VALUE="new
// line"
// node program.js --s="$VALUE"
args = parse([ "--s=X\nX" ])
t.deepEqual(args, { _ : [], s : "X\nX" });
t.end();
});
test('strings' , function (t) {
var s = parse([ '-s', '0001234' ], { string: 's' }).s;
t.equal(s, '0001234');
t.equal(typeof s, 'string');
var x = parse([ '-x', '56' ], { string: 'x' }).x;
t.equal(x, '56');
t.equal(typeof x, 'string');
t.end();
});
test('stringArgs', function (t) {
var s = parse([ ' ', ' ' ], { string: '_' })._;
t.same(s.length, 2);
t.same(typeof s[0], 'string');
t.same(s[0], ' ');
t.same(typeof s[1], 'string');
t.same(s[1], ' ');
t.end();
});
test('empty strings', function(t) {
var s = parse([ '-s' ], { string: 's' }).s;
t.equal(s, '');
t.equal(typeof s, 'string');
var str = parse([ '--str' ], { string: 'str' }).str;
t.equal(str, '');
t.equal(typeof str, 'string');
var letters = parse([ '-art' ], {
string: [ 'a', 't' ]
});
t.equal(letters.a, '');
t.equal(letters.r, true);
t.equal(letters.t, '');
t.end();
});
test('string and alias', function(t) {
var x = parse([ '--str', '000123' ], {
string: 's',
alias: { s: 'str' }
});
t.equal(x.str, '000123');
t.equal(typeof x.str, 'string');
t.equal(x.s, '000123');
t.equal(typeof x.s, 'string');
var y = parse([ '-s', '000123' ], {
string: 'str',
alias: { str: 's' }
});
t.equal(y.str, '000123');
t.equal(typeof y.str, 'string');
t.equal(y.s, '000123');
t.equal(typeof y.s, 'string');
t.end();
});
test('slashBreak', function (t) {
t.same(
parse([ '-I/foo/bar/baz' ]),
{ I : '/foo/bar/baz', _ : [] }
);
t.same(
parse([ '-xyz/foo/bar/baz' ]),
{ x : true, y : true, z : '/foo/bar/baz', _ : [] }
);
t.end();
});
test('alias', function (t) {
var argv = parse([ '-f', '11', '--zoom', '55' ], {
alias: { z: 'zoom' }
});
t.equal(argv.zoom, 55);
t.equal(argv.z, argv.zoom);
t.equal(argv.f, 11);
t.end();
});
test('multiAlias', function (t) {
var argv = parse([ '-f', '11', '--zoom', '55' ], {
alias: { z: [ 'zm', 'zoom' ] }
});
t.equal(argv.zoom, 55);
t.equal(argv.z, argv.zoom);
t.equal(argv.z, argv.zm);
t.equal(argv.f, 11);
t.end();
});
test('nested dotted objects', function (t) {
var argv = parse([
'--foo.bar', '3', '--foo.baz', '4',
'--foo.quux.quibble', '5', '--foo.quux.o_O',
'--beep.boop'
]);
t.same(argv.foo, {
bar : 3,
baz : 4,
quux : {
quibble : 5,
o_O : true
}
});
t.same(argv.beep, { boop : true });
t.end();
});

View File

@@ -0,0 +1,9 @@
var parse = require('../');
var test = require('tape');
test('parse with modifier functions' , function (t) {
t.plan(1);
var argv = parse([ '-b', '123' ], { boolean: 'b' });
t.deepEqual(argv, { b: true, _: [123] });
});

View File

@@ -0,0 +1,67 @@
var parse = require('../');
var test = require('tape');
test('numeric short args', function (t) {
t.plan(2);
t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] });
t.deepEqual(
parse([ '-123', '456' ]),
{ 1: true, 2: true, 3: 456, _: [] }
);
});
test('short', function (t) {
t.deepEqual(
parse([ '-b' ]),
{ b : true, _ : [] },
'short boolean'
);
t.deepEqual(
parse([ 'foo', 'bar', 'baz' ]),
{ _ : [ 'foo', 'bar', 'baz' ] },
'bare'
);
t.deepEqual(
parse([ '-cats' ]),
{ c : true, a : true, t : true, s : true, _ : [] },
'group'
);
t.deepEqual(
parse([ '-cats', 'meow' ]),
{ c : true, a : true, t : true, s : 'meow', _ : [] },
'short group next'
);
t.deepEqual(
parse([ '-h', 'localhost' ]),
{ h : 'localhost', _ : [] },
'short capture'
);
t.deepEqual(
parse([ '-h', 'localhost', '-p', '555' ]),
{ h : 'localhost', p : 555, _ : [] },
'short captures'
);
t.end();
});
test('mixed short bool and capture', function (t) {
t.same(
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
{
f : true, p : 555, h : 'localhost',
_ : [ 'script.js' ]
}
);
t.end();
});
test('short and long', function (t) {
t.deepEqual(
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
{
f : true, p : 555, h : 'localhost',
_ : [ 'script.js' ]
}
);
t.end();
});

View File

@@ -0,0 +1,15 @@
var parse = require('../');
var test = require('tape');
test('stops parsing on the first non-option when stopEarly is set', function (t) {
var argv = parse(['--aaa', 'bbb', 'ccc', '--ddd'], {
stopEarly: true
});
t.deepEqual(argv, {
aaa: 'bbb',
_: ['ccc', '--ddd']
});
t.end();
});

View File

@@ -0,0 +1,102 @@
var parse = require('../');
var test = require('tape');
test('boolean and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'true', '--derp', 'true' ];
var regular = [ '--herp', 'true', '-d', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h',
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, ['--derp', '-d']);
t.end();
});
test('flag boolean true any double hyphen argument is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var argv = parse(['--honk', '--tacos=good', 'cow', '-p', '55'], {
boolean: true,
unknown: unknownFn
});
t.same(unknown, ['--tacos=good', 'cow', '-p']);
t.same(argv, {
honk: true,
_: []
});
t.end();
});
test('string and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'hello', '--derp', 'goodbye' ];
var regular = [ '--herp', 'hello', '-d', 'moon' ];
var opts = {
alias: { h: 'herp' },
string: 'h',
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, ['--derp', '-d']);
t.end();
});
test('default and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'hello' ];
var regular = [ '--herp', 'hello' ];
var opts = {
default: { 'h': 'bar' },
alias: { 'h': 'herp' },
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, []);
t.end();
unknownFn(); // exercise fn for 100% coverage
});
test('value following -- is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '--bad', '--', 'good', 'arg' ];
var opts = {
'--': true,
unknown: unknownFn
};
var argv = parse(aliased, opts);
t.same(unknown, ['--bad']);
t.same(argv, {
'--': ['good', 'arg'],
'_': []
})
t.end();
});

View File

@@ -0,0 +1,8 @@
var parse = require('../');
var test = require('tape');
test('whitespace should be whitespace' , function (t) {
t.plan(1);
var x = parse([ '-x', '\t' ]).x;
t.equal(x, '\t');
});

88
node_modules/gonzales-pe/package.json generated vendored Normal file
View File

@@ -0,0 +1,88 @@
{
"_args": [
[
"gonzales-pe@4.2.4",
"/Users/tatiana/selfdefined"
]
],
"_from": "gonzales-pe@4.2.4",
"_id": "gonzales-pe@4.2.4",
"_inBundle": false,
"_integrity": "sha512-v0Ts/8IsSbh9n1OJRnSfa7Nlxi4AkXIsWB6vPept8FDbL4bXn3FNuxjYtO/nmBGu7GDkL9MFeGebeSu6l55EPQ==",
"_location": "/gonzales-pe",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "gonzales-pe@4.2.4",
"name": "gonzales-pe",
"escapedName": "gonzales-pe",
"rawSpec": "4.2.4",
"saveSpec": null,
"fetchSpec": "4.2.4"
},
"_requiredBy": [
"/detective-less",
"/detective-sass",
"/detective-scss"
],
"_resolved": "https://registry.npmjs.org/gonzales-pe/-/gonzales-pe-4.2.4.tgz",
"_spec": "4.2.4",
"_where": "/Users/tatiana/selfdefined",
"author": {
"name": "Tony Ganch",
"email": "tonyganch+github@gmail.com",
"url": "http://tonyganch.com"
},
"bin": {
"gonzales": "./bin/gonzales.js"
},
"bugs": {
"url": "http://github.com/tonyganch/gonzales-pe/issues"
},
"dependencies": {
"minimist": "1.1.x"
},
"description": "Gonzales Preprocessor Edition (fast CSS parser)",
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.18.0",
"coffee-script": "~1.7.1",
"eslint": "^3.0.0",
"jscs": "2.1.0",
"jshint": "2.10.2",
"json-loader": "^0.5.3",
"mocha": "2.2.x",
"webpack": "^1.12.2",
"webpack-closure-compiler": "^2.0.2"
},
"engines": {
"node": ">=0.6.0"
},
"files": [
"MIT-LICENSE.txt",
"bin/gonzales.js",
"lib/gonzales.js"
],
"homepage": "http://github.com/tonyganch/gonzales-pe",
"license": "MIT",
"main": "./lib/gonzales",
"name": "gonzales-pe",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/tonyganch/gonzales-pe.git"
},
"scripts": {
"autofix-tests": "bash ./scripts/build.sh && bash ./scripts/autofix-tests.sh",
"build": "bash ./scripts/build.sh",
"init": "bash ./scripts/init.sh",
"lint": "bash ./scripts/lint.sh",
"log": "bash ./scripts/log.sh",
"prepublishOnly": "bash ./scripts/build.sh",
"test": "bash ./scripts/test.sh",
"watch": "bash ./scripts/watch.sh"
},
"version": "4.2.4"
}