Skip to content

Commit

Permalink
Merge pull request #1600 from xodio/fix-1597-skip-special-files-in-li…
Browse files Browse the repository at this point in the history
…b-dir

Ignore some dirnames while reading directories
  • Loading branch information
brusherru authored Dec 26, 2018
2 parents 56adcb5 + 85a4a90 commit 81ae4ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/xod-fs/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ export const CHANGE_TYPES = {
ADDED: 'ADDED',
DELETED: 'DELETED',
};

export const IGNORE_FILENAMES = [
'.*', // hidden files on Posix
'*~', // backups
'Thumbs.db', // Windows image file
'desktop.ini', // Windows folder meta information
];
3 changes: 2 additions & 1 deletion packages/xod-fs/src/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import path from 'path';
import recReadDir from 'recursive-readdir';

import { expandHomeDir } from './utils';
import { IGNORE_FILENAMES } from './constants';

// :: rootPath -> Promise
export const readDir = rootPath =>
new Promise((resolve, reject) => {
const resolvedPath = path.resolve(expandHomeDir(rootPath));
recReadDir(resolvedPath, (err, files) => {
recReadDir(resolvedPath, IGNORE_FILENAMES, (err, files) => {
if (err) {
reject(err);
return;
Expand Down

0 comments on commit 81ae4ba

Please sign in to comment.