Browse Source

Support basic file modes (#187)

now-cli should pass file mode bits when creating a deployment.
master
Olli Vanhoja 8 years ago
committed by Leo Lamprecht
parent
commit
c509dfd5d7
  1. 41
      lib/index.js

41
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
}
})

Loading…
Cancel
Save