Skip to content

Commit

Permalink
fix(import): don't treat hidden files
Browse files Browse the repository at this point in the history
  • Loading branch information
targos authored Sep 6, 2016
1 parent 21ac98a commit 3e21473
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/rest-on-couch-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ const findFiles = co.wrap(function* (homeDir) {

const databases = yield fsp.readdir(homeDir);
for (const database of databases) {
if (database === 'node_modules') continue;
if (shouldIgnore(database)) continue;
const databasePath = path.join(homeDir, database);
const stat = yield fsp.stat(databasePath);
if (!stat.isDirectory()) continue;

const importNames = yield fsp.readdir(databasePath);
for (const importName of importNames) {
if (importName === 'node_modules') continue;
if (shouldIgnore(importName)) continue;
const importNamePath = path.join(databasePath, importName);
const stat = yield fsp.stat(importNamePath);
if (!stat.isDirectory()) continue;
Expand Down Expand Up @@ -284,6 +284,11 @@ function getDatePath() {
return now.getUTCFullYear() + '/' + ('0' + (now.getUTCMonth() + 1)).slice(-2) + '/' + ('0' + now.getUTCDate()).slice(-2);
}

function shouldIgnore(name) {
return name === 'node_modules' ||
name.startsWith('.');
}

if (program.args[0]) {
debug(`file argument: ${program.args[0]}`);
// TODO add 2 arguments: db and import names
Expand Down

0 comments on commit 3e21473

Please sign in to comment.