@percy/sdk-utils
Advanced tools
Comparing version 1.0.0-beta.52 to 1.0.0-beta.53
@@ -150,2 +150,3 @@ (function() { | ||
}), { | ||
progress: this.progress.bind(this, name), | ||
deprecated: this.deprecated.bind(this, name), | ||
@@ -189,2 +190,22 @@ shouldLog: this.shouldLog.bind(this, name) | ||
return `[${label}] ${message}${suffix}`; | ||
} // Replaces the current line with a log message | ||
progress(debug, message, persist) { | ||
if (!this.shouldLog(debug, 'info')) return; | ||
let { | ||
stdout | ||
} = this.constructor; | ||
if (stdout.isTTY || !this._progress) { | ||
message && (message = this.format(message, debug)); | ||
if (stdout.isTTY) stdout.cursorTo(0);else message && (message = message + '\n'); | ||
if (message) stdout.write(message); | ||
if (stdout.isTTY) stdout.clearLine(1); | ||
} | ||
this._progress = !!message && { | ||
message, | ||
persist | ||
}; | ||
} // Returns true or false if the level and debug group can write messages to stdio | ||
@@ -255,4 +276,17 @@ | ||
write(level, message) { | ||
let stdio = level === 'info' ? 'stdout' : 'stderr'; | ||
this.constructor[stdio].write(message + '\n'); | ||
var _this$_progress; | ||
let { | ||
stdout, | ||
stderr | ||
} = this.constructor; | ||
let progress = stdout.isTTY && this._progress; | ||
if (progress) { | ||
stdout.cursorTo(0); | ||
stdout.clearLine(); | ||
} | ||
(level === 'info' ? stdout : stderr).write(message + '\n'); | ||
if (!((_this$_progress = this._progress) !== null && _this$_progress !== void 0 && _this$_progress.persist)) delete this._progress;else if (progress) stdout.write(progress.message); | ||
} // Opens a socket logging connection | ||
@@ -371,2 +405,6 @@ | ||
progress() { | ||
console.error('The log.progress() method is not supported in browsers'); | ||
} | ||
} | ||
@@ -585,2 +623,4 @@ | ||
// error message, signal that Percy has been disabled. | ||
async function postSnapshot(options) { | ||
@@ -590,2 +630,8 @@ await request('/percy/snapshot', { | ||
body: JSON.stringify(options) | ||
}).catch(err => { | ||
if (err.response && err.message === 'Closed') { | ||
info.enabled = false; | ||
} else { | ||
throw err; | ||
} | ||
}); | ||
@@ -592,0 +638,0 @@ } |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _percyInfo = _interopRequireDefault(require("./percy-info")); | ||
var _request = _interopRequireDefault(require("./request")); | ||
@@ -13,3 +15,4 @@ | ||
// Post snapshot data to the snapshot endpoint | ||
// Post snapshot data to the snapshot endpoint. If the snapshot endpoint responds with a closed | ||
// error message, signal that Percy has been disabled. | ||
async function postSnapshot(options) { | ||
@@ -19,3 +22,9 @@ await (0, _request.default)('/percy/snapshot', { | ||
body: JSON.stringify(options) | ||
}).catch(err => { | ||
if (err.response && err.message === 'Closed') { | ||
_percyInfo.default.enabled = false; | ||
} else { | ||
throw err; | ||
} | ||
}); | ||
} |
{ | ||
"name": "@percy/sdk-utils", | ||
"version": "1.0.0-beta.52", | ||
"version": "1.0.0-beta.53", | ||
"license": "MIT", | ||
@@ -49,5 +49,5 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@percy/logger": "^1.0.0-beta.52" | ||
"@percy/logger": "^1.0.0-beta.53" | ||
}, | ||
"gitHead": "ebc543f148bede5ce057458ffb830dd60823837e" | ||
"gitHead": "42c93d11a663b5e45ab75944e20f0fb63a0dda09" | ||
} |
@@ -102,2 +102,8 @@ (function() { | ||
return Object.assign(new Writable(), { | ||
isTTY: options && options.isTTY, | ||
cursorTo() {}, | ||
clearLine() {}, | ||
_write(chunk, encoding, callback) { | ||
@@ -215,3 +221,5 @@ data.push(sanitizeLog(chunk.toString(), options)); | ||
testError: path => helpers.call('server.test.error', path), | ||
testSerialize: fn => helpers.call('server.test.serialize', fn && fn.toString()), | ||
testSerialize: fn => !fn ? helpers.call('server.test.serialize') // get | ||
: helpers.call('server.test.serialize', fn), | ||
// set | ||
mockSite: () => helpers.call('site.mock'), | ||
@@ -218,0 +226,0 @@ closeSite: () => helpers.call('site.close') |
@@ -22,3 +22,5 @@ const logger = require('@percy/logger/test/helpers'); | ||
testError: path => helpers.call('server.test.error', path), | ||
testSerialize: fn => helpers.call('server.test.serialize', fn && fn.toString()), | ||
testSerialize: fn => !fn | ||
? helpers.call('server.test.serialize') // get | ||
: helpers.call('server.test.serialize', fn), // set | ||
mockSite: () => helpers.call('site.mock'), | ||
@@ -25,0 +27,0 @@ closeSite: () => helpers.call('site.close') |
@@ -134,2 +134,3 @@ // create a testing context for mocking the local percy server and a local testing site | ||
let result = await ctx.call(event, ...args); | ||
if (typeof result === 'function') result = result.toString(); | ||
ws.send(JSON.stringify({ id, resolve: { result } })); | ||
@@ -136,0 +137,0 @@ log('debug', `${event}: ${JSON.stringify({ args, result })}`); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51024
1259
Updated@percy/logger@^1.0.0-beta.53