Skip to content

Commit

Permalink
fix colors
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Nov 23, 2024
1 parent 0d944b0 commit b25120e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
20 changes: 8 additions & 12 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ fs = require 'fs'
os = require 'os'
path = require 'path'
stream = require 'stream'
_ = require 'underscore'
{ spawn, exec, execSync } = require 'child_process'
CoffeeScript = require './lib/coffeescript'
helpers = require './lib/coffeescript/helpers'
Expand Down Expand Up @@ -36,7 +35,8 @@ task = (name, description, action) ->

# ANSI Terminal Colors.
bold = red = green = yellow = reset = ''
if process.stdout.hasColors() and not process.env.NODE_DISABLE_COLORS
USE_COLORS = process.stdout.hasColors?() and not process.env.NODE_DISABLE_COLORS
if USE_COLORS
bold = '\x1B[0;1m'
red = '\x1B[0;31m'
green = '\x1B[0;32m'
Expand Down Expand Up @@ -80,18 +80,12 @@ class TopLevelError extends AggregateError
if e instanceof AggregateError
aggregateStack.push ...e.errors.reverse()
else if e instanceof TaskFailed
title = e.title()
console.error "task failed: #{title}"
operation = e.operation()
console.info util.styleText ['yellow'], "operation: #{operation}"
reason = e.reason()
console.info util.styleText ['cyan'], "reason: #{reason}"
inner = e.inner()
if inner?
console.error util.styleText 'reset', inner
e.print console, {useColors: USE_COLORS}

if (heading = e.heading?())?
console.error util.styleText ['underline', 'magenta', 'italic'], heading
if USE_COLORS
heading = util.styleText ['underline', 'magenta', 'italic'], heading
console.error heading

process.exit 1

Expand Down Expand Up @@ -286,6 +280,8 @@ task 'build:watch:harmony', 'watch and continually rebuild the CoffeeScript comp


buildDocs = (watch = no) ->
_ = require 'underscore'

# Constants
indexFile = 'documentation/site/index.html'
siteSourceFolder = "documentation/site"
Expand Down
31 changes: 24 additions & 7 deletions build-support/caching.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
assert = require 'assert'
{ createHash } = require 'crypto'
fs = require 'fs'
path = require 'path'
{ performance } = require 'perf_hooks'
stream = require 'stream'
helpers = require '../lib/coffeescript/helpers'
assert = require 'assert'
fs = require 'fs'
helpers = require '../lib/coffeescript/helpers'
path = require 'path'
stream = require 'stream'
util = require 'util'
{ createHash } = require 'crypto'
{ performance } = require 'perf_hooks'


exports.Content = class Content
Expand Down Expand Up @@ -135,6 +136,22 @@ exports.TaskFailed = class TaskFailed extends Error
reason: -> @cause.reason?()
inner: -> @cause.inner?()

print: (console, {useColors}) ->
console.error "task failed: #{@title()}"

operation = "operation: #{@operation()}"
if useColors
operation = util.styleText 'yellow', operation
console.info operation

reason = "reason: #{@reason()}"
if useColors
reason = util.styleText 'cyan', reason
console.info reason

if (inner = @inner())?
console.error util.styleText 'reset', inner


exports.BuildTask = class BuildTask
identifier: -> throw new TypeError "unimplemented: #{@constructor.name}"
Expand Down

0 comments on commit b25120e

Please sign in to comment.