Skip to content

Commit

Permalink
feat: use different renderer on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jul 8, 2017
1 parent a323017 commit c4a9924
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
coverage
coverage/
dist
docs
*.log
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.3",
"listr": "^0.12.0",
"listr-update-renderer": "^0.4.0",
"listr-verbose-renderer": "^0.4.0",
"lodash": "^4.17.4",
"mocha": "^3.4.2",
"npm-which": "^3.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/build/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const filesize = require('filesize')
const pify = require('pify')

const clean = require('../clean')

const utils = require('../utils')
const config = require('../config/webpack')

function webpackBuild (ctx, task) {
Expand Down Expand Up @@ -71,6 +71,6 @@ const TASKS = new Listr([{
}, {
title: 'Minify',
task: minify
}])
}], utils.getListrConfig())

module.exports = TASKS
3 changes: 2 additions & 1 deletion src/coverage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Listr = require('listr')

const providers = require('./providers')
const testNode = require('../test/node')
const utils = require('../utils')

function coverage (opts) {
const tasks = new Listr([{
Expand All @@ -22,7 +23,7 @@ function coverage (opts) {
return providers[name](coverFile)
},
enabled: (ctx) => _.includes(ctx.providers, name)
}))))
}))), utils.getListrConfig())

return tasks.run(opts)
}
Expand Down
3 changes: 2 additions & 1 deletion src/release/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Listr = require('listr')
const lint = require('../lint')
const test = require('../test')
const build = require('../build')
const utils = require('../utils')

const releaseChecks = require('./prerelease')
const bump = require('./bump')
Expand Down Expand Up @@ -55,7 +56,7 @@ function release (opts) {
title: 'Publish to npm',
task: publish,
enabled: (ctx) => ctx.publish
}])
}], utils.getListrConfig())

return releaseChecks(opts).then(() => tasks.run(opts))
}
Expand Down
14 changes: 14 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const path = require('path')
const findUp = require('find-up')
const fs = require('fs-extra')
const _ = require('lodash')
const VerboseRenderer = require('listr-verbose-renderer')
const UpdateRenderer = require('listr-update-renderer')

const PKG_FILE = 'package.json'
const DIST_FOLDER = 'dist'
Expand Down Expand Up @@ -76,3 +78,15 @@ exports.getLibraryName = (name) => {
exports.getPathToNodeModules = () => {
return path.resolve(__dirname, '../node_modules')
}

/**
* Get the config for Listr depending on the current environment.
*
* @returns {Object}
*/
exports.getListrConfig = () => {
const isCI = String(process.env.CI) !== 'undefined'
return {
renderer: isCI ? VerboseRenderer : UpdateRenderer
}
}
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4406,6 +4406,19 @@ listr-update-renderer@^0.2.0:
log-update "^1.0.2"
strip-ansi "^3.0.1"

listr-update-renderer@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/listr-update-renderer/-/listr-update-renderer-0.4.0.tgz#344d980da2ca2e8b145ba305908f32ae3f4cc8a7"
dependencies:
chalk "^1.1.3"
cli-truncate "^0.2.1"
elegant-spinner "^1.0.1"
figures "^1.7.0"
indent-string "^3.0.0"
log-symbols "^1.0.2"
log-update "^1.0.2"
strip-ansi "^3.0.1"

listr-verbose-renderer@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/listr-verbose-renderer/-/listr-verbose-renderer-0.4.0.tgz#44dc01bb0c34a03c572154d4d08cde9b1dc5620f"
Expand Down

0 comments on commit c4a9924

Please sign in to comment.