From 85a4a907dfee210bacfbc60f878432823e8feefe Mon Sep 17 00:00:00 2001 From: Kirill Shumilov Date: Tue, 25 Dec 2018 17:34:42 +0300 Subject: [PATCH] fix(xod-fs): add file/dir names to ignore while reading directories --- packages/xod-fs/src/constants.js | 7 +++++++ packages/xod-fs/src/read.js | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/xod-fs/src/constants.js b/packages/xod-fs/src/constants.js index 33ec84fd..bb27c403 100644 --- a/packages/xod-fs/src/constants.js +++ b/packages/xod-fs/src/constants.js @@ -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 +]; diff --git a/packages/xod-fs/src/read.js b/packages/xod-fs/src/read.js index 14345072..f4cff408 100644 --- a/packages/xod-fs/src/read.js +++ b/packages/xod-fs/src/read.js @@ -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;