Skip to content

Commit

Permalink
Merge pull request #169 from jasonewang/trailing-slash-fix
Browse files Browse the repository at this point in the history
Strip trailing slashes from directory argument
  • Loading branch information
jwilsson committed Apr 12, 2016
2 parents 1b49cd1 + f5dae17 commit 0a197db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lesshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
11 changes: 11 additions & 0 deletions test/specs/lesshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0a197db

Please sign in to comment.