@ -24,11 +24,15 @@ const IGNORED = require('./ignored')
* @ return { Array } comprehensive list of paths to sync
* @ return { Array } comprehensive list of paths to sync
* /
* /
async function npm ( path , pkg , {
async function npm ( path , pkg , nowConfig = null , {
limit = null ,
limit = null ,
hasNowJson = false ,
debug = false
debug = false
} = { } ) {
} = { } ) {
const whitelist = pkg . now && pkg . now . files ? pkg . now . files : pkg . files
const whitelist = ( nowConfig && nowConfig . files ) || pkg . files
// the package.json `files` whitelist still
// honors ignores: https://docs.npmjs.com/files/package.json#files
const search_ = whitelist || [ '.' ]
const search_ = whitelist || [ '.' ]
// convert all filenames into absolute paths
// convert all filenames into absolute paths
const search = Array . prototype . concat . apply ( [ ] , ( await Promise . all ( search_ . map ( file => glob ( file , { cwd : path , absolute : true , dot : true } ) ) ) ) )
const search = Array . prototype . concat . apply ( [ ] , ( await Promise . all ( search_ . map ( file => glob ( file , { cwd : path , absolute : true , dot : true } ) ) ) ) )
@ -92,6 +96,10 @@ async function npm(path, pkg, {
// source: https://docs.npmjs.com/files/package.json#files
// source: https://docs.npmjs.com/files/package.json#files
files . push ( asAbsolute ( 'package.json' , path ) )
files . push ( asAbsolute ( 'package.json' , path ) )
if ( hasNowJson ) {
files . push ( asAbsolute ( 'now.json' , path ) )
}
// get files
// get files
return unique ( files )
return unique ( files )
}
}
@ -125,12 +133,17 @@ const asAbsolute = function (path, parent) {
* @ return { Array } comprehensive list of paths to sync
* @ return { Array } comprehensive list of paths to sync
* /
* /
async function docker ( path , {
async function docker ( path , nowConfig = null , {
limit = null ,
limit = null ,
hasNowJson = false ,
debug = false
debug = false
} = { } ) {
} = { } ) {
const whitelist = nowConfig && nowConfig . files
// base search path
// base search path
const search_ = [ '.' ]
// the now.json `files` whitelist still
// honors ignores: https://docs.npmjs.com/files/package.json#files
const search_ = whitelist || [ '.' ]
// convert all filenames into absolute paths
// convert all filenames into absolute paths
const search = search_ . map ( file => asAbsolute ( file , path ) )
const search = search_ . map ( file => asAbsolute ( file , path ) )
@ -176,6 +189,10 @@ async function docker(path, {
// source: https://docs.npmjs.com/files/package.json#files
// source: https://docs.npmjs.com/files/package.json#files
files . push ( asAbsolute ( 'Dockerfile' , path ) )
files . push ( asAbsolute ( 'Dockerfile' , path ) )
if ( hasNowJson ) {
files . push ( asAbsolute ( 'now.json' , path ) )
}
// get files
// get files
return unique ( files )
return unique ( files )
}
}
@ -206,7 +223,7 @@ const glob = async function (pattern, options) {
* @ return { Array } of { String } s of full paths
* @ return { Array } of { String } s of full paths
* /
* /
const explode = async function ( paths , { accepts , debug } ) {
async function explode ( paths , { accepts , debug } ) {
const list = async file => {
const list = async file => {
let path = file
let path = file
let s
let s
@ -262,7 +279,7 @@ const explode = async function (paths, {accepts, debug}) {
const maybeRead = async function ( path , default_ = '' ) {
const maybeRead = async function ( path , default_ = '' ) {
try {
try {
return ( await readFile ( path , 'utf8' ) )
return await readFile ( path , 'utf8' )
} catch ( err ) {
} catch ( err ) {
return default_
return default_
}
}