Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 51bdaca

Browse files
committed
fix: switch to single line debug output
1 parent 276f0af commit 51bdaca

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const fs = require('./fs')
77
const browserify = require('browserify')
88
const watchify = require('watchify')
99

10-
const log = require('debug')('cypress:browserify')
10+
const debug = require('debug')('cypress:browserify')
1111

1212
const bundles = {}
1313

@@ -56,7 +56,7 @@ const defaultOptions = {
5656
// on('file:preprocessor', browserify(options))
5757
//
5858
const preprocessor = (options = {}) => {
59-
log('received user options', options)
59+
debug('received user options: %o', options)
6060

6161
// we return function that accepts the arguments provided by
6262
// the event 'file:preprocessor'
@@ -71,13 +71,13 @@ const preprocessor = (options = {}) => {
7171
// the supported file and spec file to be requested again
7272
return (file) => {
7373
const filePath = file.filePath
74-
log('get', filePath)
74+
debug('get:', filePath)
7575

7676
// since this function can get called multiple times with the same
7777
// filePath, we return the cached bundle promise if we already have one
7878
// since we don't want or need to re-initiate browserify/watchify for it
7979
if (bundles[filePath]) {
80-
log(`already have bundle for ${filePath}`)
80+
debug('already have bundle for:', filePath)
8181
return bundles[filePath]
8282
}
8383

@@ -86,8 +86,8 @@ const preprocessor = (options = {}) => {
8686
// file on disk
8787
const outputPath = file.outputPath
8888

89-
log(`input: ${filePath}`)
90-
log(`output: ${outputPath}`)
89+
debug('input:', filePath)
90+
debug('output:', outputPath)
9191

9292
// allow user to override default options
9393
const browserifyOptions = Object.assign({}, defaultOptions.browserifyOptions, options.browserifyOptions, {
@@ -102,11 +102,11 @@ const preprocessor = (options = {}) => {
102102
entries: [filePath],
103103
})
104104

105-
log('browserifyOptions:', browserifyOptions)
105+
debug('browserifyOptions %o:', browserifyOptions)
106106
const bundler = browserify(browserifyOptions)
107107

108108
if (file.shouldWatch) {
109-
log('watching')
109+
debug('watching')
110110
bundler.plugin(watchify, watchifyOptions)
111111
}
112112

@@ -123,20 +123,20 @@ const preprocessor = (options = {}) => {
123123
// the file from
124124
const bundle = () => {
125125
return new Promise((resolve, reject) => {
126-
log(`making bundle ${outputPath}`)
126+
debug(`making bundle ${outputPath}`)
127127

128128
const onError = (err) => {
129129
err.filePath = filePath
130130
// backup the original stack before its
131131
// potentially modified from bluebird
132132
err.originalStack = err.stack
133-
log(`errored bundling ${outputPath}`, err)
133+
debug(`errored bundling: ${outputPath}`, err)
134134
reject(err)
135135
}
136136

137137
const ws = fs.createWriteStream(outputPath)
138138
ws.on('finish', () => {
139-
log(`finished bundling ${outputPath}`)
139+
debug('finished bundling:', outputPath)
140140
resolve(outputPath)
141141
})
142142
ws.on('error', onError)
@@ -151,11 +151,11 @@ const preprocessor = (options = {}) => {
151151
// when we're notified of an update via watchify, signal for Cypress to
152152
// rerun the spec
153153
bundler.on('update', () => {
154-
log(`update ${filePath}`)
154+
debug('update:', filePath)
155155
// we overwrite the cached bundle promise, so on subsequent invocations
156156
// it gets the latest bundle
157157
const bundlePromise = bundle().finally(() => {
158-
log(`- update finished for ${filePath}`)
158+
debug('- update finished for:', filePath)
159159
file.emit('rerun')
160160
})
161161
bundles[filePath] = bundlePromise
@@ -176,7 +176,7 @@ const preprocessor = (options = {}) => {
176176
// when the spec or project is closed, we need to clean up the cached
177177
// bundle promise and stop the watcher via `bundler.close()`
178178
file.on('close', () => {
179-
log(`close ${filePath}`)
179+
debug('close:', filePath)
180180
delete bundles[filePath]
181181
if (file.shouldWatch) {
182182
bundler.close()

0 commit comments

Comments
 (0)