Skip to content

Commit

Permalink
chore: clean up postProcessRecording code (#7777)
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Jun 22, 2020
1 parent bf752f1 commit 6423b35
Showing 1 changed file with 69 additions and 65 deletions.
134 changes: 69 additions & 65 deletions packages/server/lib/modes/run.js
Expand Up @@ -824,84 +824,88 @@ module.exports = {
return
}

const postProcessRecordingOutput = (name, videoCompression) => {
console.log('')
function continueProcessing (onProgress = undefined) {
return videoCapture.process(name, cname, videoCompression, onProgress)
}

terminal.header('Video', {
color: ['cyan'],
})
if (quiet) {
return continueProcessing()
}

console.log('')
console.log('')

const table = terminal.table({
colWidths: [3, 21, 76],
colAligns: ['left', 'left', 'left'],
type: 'noBorder',
style: {
'padding-right': 0,
},
chars: {
'left': ' ',
'right': '',
},
})
terminal.header('Video', {
color: ['cyan'],
})

table.push([
gray('-'),
gray('Started processing:'),
chalk.cyan(`Compressing to ${videoCompression} CRF`),
])
console.log('')

console.log(table.toString())

const started = Date.now()
let progress = Date.now()
const throttle = env.get('VIDEO_COMPRESSION_THROTTLE') || human('10 seconds')

return function (float) {
if (float === 1) {
const finished = Date.now() - started
const dur = `(${humanTime.long(finished)})`

const table = terminal.table({
colWidths: [3, 21, 61, 15],
colAligns: ['left', 'left', 'left', 'right'],
type: 'noBorder',
style: {
'padding-right': 0,
},
chars: {
'left': ' ',
'right': '',
},
})
const table = terminal.table({
colWidths: [3, 21, 76],
colAligns: ['left', 'left', 'left'],
type: 'noBorder',
style: {
'padding-right': 0,
},
chars: {
'left': ' ',
'right': '',
},
})

table.push([
gray('-'),
gray('Finished processing:'),
`${formatPath(name, getWidth(table, 2), 'cyan')}`,
gray(dur),
])
table.push([
gray('-'),
gray('Started processing:'),
chalk.cyan(`Compressing to ${videoCompression} CRF`),
])

console.log(table.toString())
console.log(table.toString())

console.log('')
}
const started = Date.now()
let progress = Date.now()
const throttle = env.get('VIDEO_COMPRESSION_THROTTLE') || human('10 seconds')

if (Date.now() - progress > throttle) {
// bump up the progress so we dont
// continuously get notifications
progress += throttle
const percentage = `${Math.ceil(float * 100)}%`
const onProgress = function (float) {
if (float === 1) {
const finished = Date.now() - started
const dur = `(${humanTime.long(finished)})`

console.log(' Compression progress: ', chalk.cyan(percentage))
}
const table = terminal.table({
colWidths: [3, 21, 61, 15],
colAligns: ['left', 'left', 'left', 'right'],
type: 'noBorder',
style: {
'padding-right': 0,
},
chars: {
'left': ' ',
'right': '',
},
})

table.push([
gray('-'),
gray('Finished processing:'),
`${formatPath(name, getWidth(table, 2), 'cyan')}`,
gray(dur),
])

console.log(table.toString())

console.log('')
}
}

const onProgress = quiet ? undefined : postProcessRecordingOutput(name, videoCompression)
if (Date.now() - progress > throttle) {
// bump up the progress so we dont
// continuously get notifications
progress += throttle
const percentage = `${Math.ceil(float * 100)}%`

console.log(' Compression progress: ', chalk.cyan(percentage))
}
}

return videoCapture.process(name, cname, videoCompression, onProgress)
return continueProcessing(onProgress)
},

launchBrowser (options = {}) {
Expand Down

4 comments on commit 6423b35

@cypress-bot

This comment was marked as off-topic.

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6423b35 Jun 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.9.0/win32-x64/appveyor-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-33671100/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.9.0/appveyor-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-33671100/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.9.0/win32-x64/appveyor-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-33671100/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.9.0/appveyor-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-33671100/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.9.0/win32-x64/appveyor-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-33671100/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.9.0/appveyor-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-33671100/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.9.0/win32-x64/appveyor-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-33671100/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.9.0/appveyor-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-33671100/cypress.tgz

@cypress-bot

This comment was marked as off-topic.

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6423b35 Jun 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.9.0/darwin-x64/circle-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-373850/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.9.0/circle-develop-6423b352daf348a07af5fe98c62b518d6ddcbdb9-373711/cypress.tgz

Please sign in to comment.