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. 26
      bin/now-deploy.js
  2. 5
      lib/index.js

26
bin/now-deploy.js

@ -524,10 +524,12 @@ async function sync({ token, config: { currentTeam, user } }) {
const startU = new Date()
const complete = () => {
const complete = ({ fileCount }) => {
if (!quiet) {
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…')
}
@ -574,12 +576,18 @@ async function sync({ token, config: { currentTeam, user } }) {
}
if (now.syncAmount) {
const bar = new Progress('> Upload [:bar] :percent :etas', {
width: 20,
complete: '=',
incomplete: '',
total: now.syncAmount
})
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,
complete: '=',
incomplete: '',
total: now.syncAmount,
clear: true
}
)
now.upload()
@ -593,7 +601,7 @@ async function sync({ token, config: { currentTeam, user } }) {
bar.tick(amount)
})
now.on('complete', complete)
now.on('complete', () => complete({ fileCount }))
now.on('error', err => {
error('Upload failed')

5
lib/index.js

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

Loading…
Cancel
Save