Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@percy/sdk-utils

Package Overview
Dependencies
Maintainers
6
Versions
223
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@percy/sdk-utils - npm Package Compare versions

Comparing version 1.0.0-beta.29 to 1.0.0-beta.30

39

index.js

@@ -1,7 +0,6 @@

// Maybe get the CLI API address and loglevel from the environment
const {
PERCY_CLI_API = 'http://localhost:5338',
PERCY_LOGLEVEL = 'info'
} = process.env;
const logger = require('@percy/logger');
// Maybe get the CLI API address from the environment
const { PERCY_CLI_API = 'http://localhost:5338' } = process.env;
// Helper to send a request to the local CLI API

@@ -42,19 +41,2 @@ function request(path, { body, ...options } = {}) {

// Log colored labels and errors using loglevels
let linereg = /^.*$/gm;
function log(level, msg) {
let l = { debug: 0, info: 1, warn: 2, error: 3 };
if (l[PERCY_LOGLEVEL] == null || l[level] < l[PERCY_LOGLEVEL]) return;
let c = (n, s) => s.replace(linereg, l => `\u001b[${n}m${l}\u001b[39m`);
if (level === 'error' || msg.stack) {
msg = (PERCY_LOGLEVEL === 'debug' && msg.stack) || msg.toString();
console.error(`[${c(35, 'percy')}] ${c(31, msg)}`);
} else if (level === 'warn') {
console.warn(`[${c(35, 'percy')}] ${c(33, msg)}`);
} else {
console.log(`[${c(35, 'percy')}] ${msg}`);
}
}
// Returns CLI information

@@ -64,3 +46,3 @@ function getInfo() {

cliApi: PERCY_CLI_API,
loglevel: PERCY_LOGLEVEL,
loglevel: logger.loglevel(),
version: getInfo.version,

@@ -82,2 +64,3 @@ config: getInfo.config

if (isPercyEnabled.result == null) {
let log = logger('util');
let error;

@@ -96,8 +79,8 @@

if (getInfo.version && getInfo.version[0] !== 1) {
log('info', 'Unsupported Percy CLI version, disabling snapshots');
log('debug', `Found version: ${getInfo.version}`);
log.info('Unsupported Percy CLI version, disabling snapshots');
log.debug(`Found version: ${getInfo.version}`);
isPercyEnabled.result = false;
} else if (!isPercyEnabled.result) {
log('info', 'Percy is not running, disabling snapshots');
log('debug', error);
log.info('Percy is not running, disabling snapshots');
log.debug(error);
}

@@ -128,3 +111,3 @@ }

module.exports = {
log,
logger,
getInfo,

@@ -131,0 +114,0 @@ isPercyEnabled,

{
"name": "@percy/sdk-utils",
"version": "1.0.0-beta.29",
"version": "1.0.0-beta.30",
"license": "MIT",

@@ -21,3 +21,6 @@ "main": "index.js",

},
"gitHead": "d8ece55981a5b9ef52abda65783c2aa874ac87e6"
"dependencies": {
"@percy/logger": "^1.0.0-beta.30"
},
"gitHead": "584a401d8cb349a90d0eea964c6ac2a3682591f1"
}
const createTestServer = require('@percy/core/test/helpers/server');
const sdk = {};
const logger = require('@percy/logger/test/helper');
const sdk = { logger };

@@ -26,3 +27,3 @@ // mock serialization script

sdk.serializeDOM = serializeDOM;
sdk.stdio[1] = []; sdk.stdio[2] = [];
logger.mock();

@@ -59,27 +60,2 @@ let utils = require('..');

sdk.stdio = function stdio(fn, { colors = false } = {}) {
// eslint-disable-next-line no-control-regex
let format = s => colors ? s : s.replace(/\x1B\[\d+m/g, '');
let out = process.stdout.write;
let err = process.stderr.write;
let r, e;
let done = (r, e) => {
process.stdout.write = out;
process.stderr.write = err;
if (e) throw e;
return r;
};
process.stdout.write = s => stdio[1].push(format(s));
process.stderr.write = s => stdio[2].push(format(s));
try { r = fn(); } catch (err) { e = err; }
if (!e && r && typeof r.then === 'function') {
return r.then(done, e => done(r, e));
} else {
return done(r, e);
}
};
module.exports = sdk;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc