diff --git a/lib/cli.spec.ts b/lib/cli.spec.ts index ffa49d5..874bddc 100644 --- a/lib/cli.spec.ts +++ b/lib/cli.spec.ts @@ -68,7 +68,9 @@ describe('eclint cli', function() { describe('check', () => { it('All Files', () => { return eclint(['check']).then(files => { + files = files.map(file => file.path); expect(files).to.have.length.above(10); + expect(files).that.include(path.resolve(__dirname, '../.gitignore')); }); }); it('Directories', () => { @@ -109,6 +111,15 @@ describe('eclint cli', function() { expect(files).have.lengthOf(0); }); }); + it('error of gulp-exclude-gitignore', () => { + return expect(() => { + eclint(['check', '/etc/hosts'], { + 'gulp-exclude-gitignore': () => { + throw new Error('test: gulp-exclude-gitignore mock'); + } + }); + }).throws('test: gulp-exclude-gitignore mock'); + }); }); describe('infer', function() { @@ -142,6 +153,7 @@ describe('eclint cli', function() { }); }); }); + describe('fix', function() { it('README.md', () => { eclint(['fix', 'README.md']).then(files => { diff --git a/lib/cli.ts b/lib/cli.ts index b572ef1..61a9674 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -2,6 +2,7 @@ import _ = require('lodash'); import tap = require('gulp-tap'); import vfs = require('vinyl-fs'); import eclint = require('./eclint'); +import excludeGitignore = require('gulp-exclude-gitignore'); import yargs = require('yargs'); import reporter = require('gulp-reporter'); import filter = require('gulp-filter'); @@ -13,15 +14,15 @@ import i18n = require('./i18n'); import path = require('path'); import fs = require('fs'); -/* - * bugfix for thomas-lebeau/gulp-gitignore#2 - */ function gitignore(): Stream { - const stream = require('gulp-gitignore')(); - if (stream instanceof Stream) { - return stream; - } else { - return gutil.noop(); + try { + return excludeGitignore(); + } catch (ex) { + if (ex.code === 'ENOENT') { + return gutil.noop(); + } else { + throw ex; + } } } @@ -191,6 +192,7 @@ function handler(yargs: Argv): Stream.Transform { globs = globs.concat(ignore); yargs.globs = globs; return vfs.src(globs, { + dot: true, stripBOM: false, removeBOM: false, }) diff --git a/package.json b/package.json index 0ef7be1..dfb8619 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eclint", - "version": "2.4.3", + "version": "2.5.0", "description": "Validate or fix code that doesn't adhere to EditorConfig settings or infer settings from existing code.", "keywords": [ "editorconfig", @@ -62,8 +62,8 @@ "dependencies": { "editorconfig": "^0.15.0", "file-type": "^7.2.0", + "gulp-exclude-gitignore": "^1.2.0", "gulp-filter": "^5.0.1", - "gulp-gitignore": "^0.1.0", "gulp-reporter": "^2.4.2", "gulp-tap": "^1.0.1", "gulp-util": "^3.0.8",