Browse Source

Ignore special files on deploy (#115)

Fixes #112
master
Olli Vanhoja 8 years ago
committed by Tony Kovanen
parent
commit
1de3b40fc4
  1. 27
      lib/get-files.js
  2. 1
      package.json

27
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
}

1
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": {

Loading…
Cancel
Save