Browse Source

Added file count, fix #370 (#558)

* Add file count, fix #370

* Remove progress-bar when complete
master
Albin Ekblom 8 years ago
committed by Leo Lamprecht
parent
commit
1224aa6d87
  1. 20
      bin/now-deploy.js
  2. 5
      lib/index.js

20
bin/now-deploy.js

@ -524,10 +524,12 @@ async function sync({ token, config: { currentTeam, user } }) {
const startU = new Date() const startU = new Date()
const complete = () => { const complete = ({ fileCount }) => {
if (!quiet) { if (!quiet) {
const elapsedU = ms(new Date() - startU) const elapsedU = ms(new Date() - startU)
console.log(`> Sync complete (${bytes(now.syncAmount)}) [${elapsedU}] `) console.log(
`> Synced ${fileCount} (${bytes(now.syncAmount)}) [${elapsedU}] `
)
console.log('> Initializing…') console.log('> Initializing…')
} }
@ -574,12 +576,18 @@ async function sync({ token, config: { currentTeam, user } }) {
} }
if (now.syncAmount) { if (now.syncAmount) {
const bar = new Progress('> Upload [:bar] :percent :etas', { const size = bytes(now.syncAmount)
const fileCount = `${now.fileCount} file${now.fileCount > 1 && 's'}`
const bar = new Progress(
`> Upload [:bar] :percent :etas (${size}) [${fileCount}]`,
{
width: 20, width: 20,
complete: '=', complete: '=',
incomplete: '', incomplete: '',
total: now.syncAmount total: now.syncAmount,
}) clear: true
}
)
now.upload() now.upload()
@ -593,7 +601,7 @@ async function sync({ token, config: { currentTeam, user } }) {
bar.tick(amount) bar.tick(amount)
}) })
now.on('complete', complete) now.on('complete', () => complete({ fileCount }))
now.on('error', err => { now.on('error', err => {
error('Upload failed') error('Upload failed')

5
lib/index.js

@ -256,6 +256,7 @@ module.exports = class Now extends EventEmitter {
this._id = deployment.deploymentId this._id = deployment.deploymentId
this._host = deployment.url this._host = deployment.url
this._missing = deployment.missing || [] this._missing = deployment.missing || []
this._fileCount = files.length
return this._url return this._url
} }
@ -825,6 +826,10 @@ module.exports = class Now extends EventEmitter {
return `https://${this._host}` return `https://${this._host}`
} }
get fileCount() {
return this._fileCount
}
get host() { get host() {
return this._host return this._host
} }

Loading…
Cancel
Save