Skip to content

Commit

Permalink
[init][s]: skip directories and files that starts with '.' - refs dat…
Browse files Browse the repository at this point in the history
  • Loading branch information
anuveyatsu committed Apr 25, 2018
1 parent 0443a38 commit 22a8f82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ class Init extends EventEmitter {
*/
scanAllDir(dir, done) {
let results = []
// If the directory name starts with '.' don't scan it:
if (dir !== './' && path.basename(dir).startsWith('.')) {
this.emit('message', `Don't scan "${path.basename(dir)}" as it starts with '.' and it might be a system/hidden directory.`)
return done(null, results)
}
// Otherwise scan the dir:
fs.readdir(dir, (err, list) => {
if (err) return done(err)
let pending = list.length
Expand Down Expand Up @@ -257,6 +263,9 @@ class Init extends EventEmitter {
this.addDescriptionAndReadme(buffer.toString())
}
return
} else if (file.descriptor.name.startsWith('.')) {
this.emit('message', `Detected file that starts with '.' and it's not added to resources: "${file.descriptor.path}"`)
return
}
// By checking extension of file, guess if it's tabular. If so enerate schema:
const knownTabularFormats = ['csv', 'tsv', 'dsv']
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/readdir test/.sample-dir/sample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file shouldn't be in the resources as it is inside "hidden" directory (starts with .).
1 change: 1 addition & 0 deletions test/fixtures/readdir test/.sample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file shouldn't be in the resources as it is a "hidden" file (starts with .).

0 comments on commit 22a8f82

Please sign in to comment.