Skip to content

Commit

Permalink
Merge pull request sasstools#330 from DanPurdy/hotfix/ignore-files
Browse files Browse the repository at this point in the history
Hotfix develop: Fix ignored files
  • Loading branch information
bgriffith committed Oct 28, 2015
2 parents 4e4e3ad + 74f6b5c commit 0fc57fc
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pids
*.pid
*.seed

# OSX
._*
.DS_Store

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

Expand Down
2 changes: 1 addition & 1 deletion bin/sass-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ program
.version(meta.version)
.usage('[options] <pattern>')
.option('-c, --config [path]', 'path to custom config file')
.option('-i, --ignore [pattern]', 'pattern to ignore. For multiple ignores, separate each pattern by `, `')
.option('-i, --ignore [pattern]', 'pattern to ignore. For multiple ignores, separate each pattern by `, ` within a string')
.option('-q, --no-exit', 'do not exit on errors')
.option('-v, --verbose', 'verbose output')
.option('-f, --format [format]', 'pass one of the available eslint formats')
Expand Down
20 changes: 12 additions & 8 deletions docs/cli/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ Sass Lint can be run via its Command Line Interface (CLI). To do so, run `sass-l

By default, the command will run against the glob defined by a user's `file.include` option in their config, or a glob (or single file) can be passed as the last argument to the CLI to be explicitly run against.

> Please note that when using glob patterns such as `folder/**/*.scss` as a command line argument (files to be linted or ignored) you will need to wrap the pattern in quotes or escape the `*` characters to prevent bash/zsh from automatically expanding the glob pattern.
## Options

The following options are available for the CLI:

* `-h, --help`: Outputs usage information for the CLI
* `-V, --version`: Outputs the version number of Sass Lint
* `-c, --config [path]`: Path to the config file that should be used, relative to the directory the the command is being run in (will override other config path options)
* `-i, --ignore [pattern]`: A pattern that should be ignored from linting. Multiple patterns can be used by separating each pattern by `, `. Patterns should be wrapped in quotes (will be merged with other ignore options)
* `-q, --no-exit`: Prevents the CLI from throwing an error if there is one (useful for development work)
* `-v, --verbose`: Verbose output (fully formatted output)
* `-f, --format [format]`: Pass one of the available [Eslint formats](https://github.com/eslint/eslint/tree/master/lib/formatters) to format the output of sass-lint results.
* `-o, --output [output]`: The path plus file name relative to where Sass Lint is being run from where the output should be written to.
Command Line Flag | Description
-------------------------|------------------------------------
`-c`,`--config [path]` | Path to the config file that should be used, relative to the directory the the command is being run in (will override other config path options)
`-f`,`--format [format]` | Pass one of the available [Eslint formats](https://github.com/eslint/eslint/tree/master/lib/formatters) to format the output of sass-lint results.
`-h`,`--help` | Outputs usage information for the CLI
`-i`,`--ignore [pattern]` | A pattern that should be ignored from linting. Multiple patterns can be used by separating each pattern by `, `. Patterns should be wrapped in quotes (will be merged with other ignore options)
`-o`,`--output [output]` | The path plus file name relative to where Sass Lint is being run from where the output should be written to.
`-q`,`--no-exit` | Prevents the CLI from throwing an error if there is one (useful for development work)
`-v`,`--verbose` | Verbose output (fully formatted output)
`-V`,`--version` | Outputs the version number of Sass Lint
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ sassLint.lintText = function (file, options, configPath) {

sassLint.lintFiles = function (files, options, configPath) {
var that = this,
results = [];
results = [],
ignores = '';

if (files) {
files = glob.sync(files);
ignores = this.getConfig(options, configPath).files.ignore || '';
files = glob.sync(files, {ignore: ignores});
}
else {
files = this.getConfig(options, configPath).files;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"commander": "^2.8.1",
"eslint": "^1.1.0",
"fs-extra": "^0.24.0",
"glob": "^4.3.5",
"glob": "^5.0.15",
"gonzales-pe": "3.0.0-31",
"js-yaml": "^3.2.6",
"merge": "^1.2.0",
Expand Down
46 changes: 46 additions & 0 deletions tests/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,50 @@ describe('cli', function () {
}
});
});

it('should not include ignored paths', function (done) {

var sassTestsPath = path.join(__dirname, '/sass/'),
files = [];

files.push(sassTestsPath + fs.readdirSync(sassTestsPath));

var command = 'sass-lint -i \'**/*.s+(a|c)ss\'';

childProcess.exec(command, function (err, stdout) {

if (err) {
return done(err);
}

files.forEach(function (file) {
assert(stdout.indexOf(file) === -1);
});

done();
});
});

it('should not include multiple ignored paths', function (done) {

var sassTestsPath = path.join(__dirname, '/sass/'),
files = [];

files.push(sassTestsPath + fs.readdirSync(sassTestsPath));

var command = 'sass-lint -i \'**/*.scss, **/*.sass \'';

childProcess.exec(command, function (err, stdout) {

if (err) {
return done(err);
}

files.forEach(function (file) {
assert(stdout.indexOf(file) === -1);
});

done();
});
});
});

0 comments on commit 0fc57fc

Please sign in to comment.