diff --git a/lib/index.js b/lib/index.js index dc3357d..a03eb6d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,11 +6,11 @@ import EventEmitter from 'events' // Packages import bytes from 'bytes' import chalk from 'chalk' -import retry from 'async-retry' -import {parse as parseIni} from 'ini' -import {readFile} from 'fs-promise' import resumer from 'resumer' +import retry from 'async-retry' import splitArray from 'split-array' +import {parse as parseIni} from 'ini' +import {readFile, stat} from 'fs-promise' // Ours import {npm as getNpmFiles, docker as getDockerFiles} from './get-files' @@ -124,6 +124,25 @@ export default class Now extends EventEmitter { console.time('> [debug] /now/create') } + // Flatten the array to contain files to sync where each nested input + // array has a group of files with the same sha but different path + const files = await Promise.all(Array.prototype.concat.apply([], await Promise.all((Array.from(this._files)).map(async ([sha, {data, names}]) => { + return await names.map(async name => { + if (this._static && toRelative(name, this._path) !== 'package.json') { + name = this.pathInsideContent(name) + } + + const st = await stat(name) + + return { + sha, + size: data.length, + file: toRelative(name, this._path), + mode: st.mode + } + }) + })))) + const res = await this._fetch('/now/create', { method: 'POST', body: { @@ -135,21 +154,7 @@ export default class Now extends EventEmitter { description, deploymentType, registryAuthToken: authToken, - // Flatten the array to contain files to sync where each nested input - // array has a group of files with the same sha but different path - files: Array.prototype.concat.apply([], Array.from(this._files).map(([sha, {data, names}]) => { - return names.map(n => { - if (this._static && toRelative(n, this._path) !== 'package.json') { - n = this.pathInsideContent(n) - } - - return { - sha, - size: data.length, - file: toRelative(n, this._path) - } - }) - })), + files, engines } })