diff --git a/lib/get-files.js b/lib/get-files.js index 152923f..5daec1a 100644 --- a/lib/get-files.js +++ b/lib/get-files.js @@ -3,8 +3,9 @@ import {resolve} from 'path' // Packages import flatten from 'arr-flatten' -import unique from 'array-unique' import ignore from 'ignore' +import Mode from 'stat-mode' +import unique from 'array-unique' import {stat, readdir, readFile} from 'fs-promise' // Ours @@ -51,13 +52,22 @@ export async function npm(path, pkg, { ).createFilter() const prefixLength = path.length + 1 - const accepts = function (file) { + const accepts = async function (file) { const relativePath = file.substr(prefixLength) if (relativePath === '') { return true } + const st = await stat(file) + const mode = new Mode(st) + if (!(mode.isDirectory() || mode.isFile() || mode.isSymbolicLink())) { + if (debug) { + console.log('> [debug] ignoring special file "%s"', file) + } + return false + } + const accepted = filter(relativePath) if (!accepted && debug) { console.log('> [debug] ignoring "%s"', file) @@ -135,13 +145,22 @@ export async function docker(path, { ).createFilter() const prefixLength = path.length + 1 - const accepts = function (file) { + const accepts = async function (file) { const relativePath = file.substr(prefixLength) if (relativePath === '') { return true } + const st = await stat(file) + const mode = new Mode(st) + if (!(mode.isDirectory() || mode.isFile() || mode.isSymbolicLink())) { + if (debug) { + console.log('> [debug] ignoring special file "%s"', file) + } + return false + } + const accepted = filter(relativePath) if (!accepted && debug) { console.log('> [debug] ignoring "%s"', file) @@ -187,7 +206,7 @@ const explode = async function (paths, {accepts}) { let path = file let s - if (!accepts(file)) { + if (!(await accepts(file))) { return null } diff --git a/package.json b/package.json index bc375e0..2e45959 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "socket.io-client": "1.4.8", "spdy": "3.4.4", "split-array": "1.0.1", + "stat-mode": "0.2.2", "text-table": "0.2.0" }, "devDependencies": {