Skip to content

Commit

Permalink
Merge pull request #12 from poppinlp/issue7
Browse files Browse the repository at this point in the history
Support ignoring specific files
  • Loading branch information
rasshofer committed Mar 4, 2018
2 parents 97128d1 + a3f0f17 commit ac23a14
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

> A simple (CLI) tool to lint YAML files
[![Build Status](https://travis-ci.org/rasshofer/yaml-lint.svg)](https://travis-ci.org/rasshofer/yaml-lint)
[![Dependency Status](https://david-dm.org/rasshofer/yaml-lint/status.svg)](https://david-dm.org/rasshofer/yaml-lint)
[![Dependency Status](https://david-dm.org/rasshofer/yaml-lint/dev-status.svg)](https://david-dm.org/rasshofer/yaml-lint)
[![Build Status](https://img.shields.io/travis/rasshofer/yaml-lint.svg?style=flat-square)](https://travis-ci.org/rasshofer/yaml-lint)
[![Dependency Status](https://img.shields.io/david/rasshofer/yaml-lint.svg?style=flat-square)](https://david-dm.org/rasshofer/yaml-lint)
[![Dev Dependency Status](https://img.shields.io/david/dev/rasshofer/yaml-lint.svg?style=flat-square)](https://david-dm.org/rasshofer/yaml-lint)
[![Version](https://img.shields.io/npm/v/yaml-lint.svg?style=flat-square)](https://www.npmjs.com/package/yaml-lint)
[![Month Download](https://img.shields.io/npm/dm/yaml-lint.svg?style=flat-square)](https://www.npmjs.com/package/yaml-lint)
[![License](https://img.shields.io/npm/l/yaml-lint.svg?style=flat-square)](https://www.npmjs.com/package/yaml-lint)

## Usage

Expand Down Expand Up @@ -44,6 +47,16 @@ $ yamllint test.yaml
- `CORE_SCHEMA` Same as `JSON_SCHEMA` ([http://www.yaml.org/spec/1.2/spec.html#id2804923](http://www.yaml.org/spec/1.2/spec.html#id2804923))
- `DEFAULT_SAFE_SCHEMA` All supported YAML types, without unsafe ones (`!!js/undefined`, `!!js/regexp`, and `!!js/function`) ([http://yaml.org/type/](http://yaml.org/type/))

### `ignore-path` (string)

> Specifies a glob or globs to ignore
Sample:

```shell
$ yamllint **/*.(yaml|yml) --ignore-path=foobar.yml --ignore-path=dir/*.yaml
```

## Changelog

* 1.1.0
Expand Down
13 changes: 9 additions & 4 deletions cli.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

const path = require('path');
const nconf = require('nconf');
const yamlLint = require('./yaml-lint');
const leprechaun = require('leprechaun');
const snakeCase = require('lodash.snakecase');
const glob = require('glob');
const yamlLint = require('./yaml-lint');

const options = {};

Expand All @@ -16,7 +16,8 @@ nconf.argv().env({
});

[
'schema'
'schema',
'ignorePath'
].forEach((key) => {
const env = snakeCase(key);
options[key] = nconf.get(key) || nconf.get('yamllint_' + env.toLowerCase()) || nconf.get('YAMLLINT' + env.toUpperCase());
Expand All @@ -26,8 +27,12 @@ const config = nconf.get();

let files = [];

(config._ || []).forEach((file) => {
files = files.concat(glob.sync(file));
(config._ || []).forEach((pattern) => {
files = files.concat(glob.sync(pattern, {
nocase: true,
dot: true,
ignore: config.ignorePath
}));
});

if (files.length === 0) {
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ac23a14

Please sign in to comment.