fix(xod-fs): add file/dir names to ignore while reading directories

This commit is contained in:
Kirill Shumilov
2018-12-25 17:34:42 +03:00
parent 56adcb5122
commit 85a4a907df
2 changed files with 9 additions and 1 deletions

View File

@@ -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
];

View File

@@ -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;