From f5dae1705bb8268fb61d993f40d7e2147acd6c4e Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Wed, 6 Apr 2016 18:44:22 -0700 Subject: [PATCH] Strip trailing slashes from directory argument -Fixes case where report fullPath field would have multiple slashes separating directories --- lib/lesshint.js | 2 +- test/specs/lesshint.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/lesshint.js b/lib/lesshint.js index fa25b6c9..c433f52f 100644 --- a/lib/lesshint.js +++ b/lib/lesshint.js @@ -15,7 +15,7 @@ var Lesshint = function () { Lesshint.prototype.checkDirectory = function (checkPath) { return fs.listDir(checkPath).then(function (files) { files = files.map(function (file) { - var fullPath = checkPath + '/' + file; + var fullPath = path.join(checkPath, file); return fs.stat(fullPath).then(function (stats) { if (stats.isDirectory()) { diff --git a/test/specs/lesshint.js b/test/specs/lesshint.js index 82581d49..6ab1e2c3 100644 --- a/test/specs/lesshint.js +++ b/test/specs/lesshint.js @@ -19,6 +19,17 @@ describe('lesshint', function () { }); }); + it('should strip trailing slashes from directory names', function () { + var testPath = path.dirname(__dirname) + '/data/files/sub/'; + var lesshint = new Lesshint(); + + lesshint.configure(); + + return lesshint.checkDirectory(testPath).then(function (result) { + expect(result[0].fullPath).to.equal(testPath + 'file.less'); + }); + }); + it('should ignore dotfiles', function () { var testPath = path.dirname(__dirname) + '/data/ignored-files'; var lesshint = new Lesshint();