New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lhci/utils

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lhci/utils - npm Package Compare versions

Comparing version 0.3.5 to 0.3.6

5

package.json
{
"name": "@lhci/utils",
"version": "0.3.5",
"version": "0.3.6",
"license": "Apache-2.0",

@@ -14,5 +14,6 @@ "repository": {

"isomorphic-fetch": "^2.2.1",
"js-yaml": "^3.13.1",
"tree-kill": "^1.2.1"
},
"gitHead": "b7cbedeb66b2d2170f3000be715974de3041d145"
"gitHead": "adfbd102aebaf954bbf67879f57e5d3fa9ee2eb6"
}

29

src/lighthouserc.js

@@ -10,10 +10,16 @@ /**

const path = require('path');
const yaml = require('js-yaml');
const _ = require('./lodash.js');
// prettier-ignore
const RC_FILE_NAMES = [
'.lighthouserc.json',
'lighthouserc.json',
'.lighthouserc.yml',
'lighthouserc.yml',
'.lighthouserc.yaml',
'lighthouserc.yaml',
];
const YAML_FILE_EXTENSION_REGEX = /\.(yml|yaml)$/i;
/**

@@ -46,2 +52,3 @@ * Yargs will treat any key with a `.` in the name as a specifier for an object subpath.

/**
* Load file, parse and convert all `.` in key names to `:`
* @param {string} pathToRcFile

@@ -51,5 +58,6 @@ * @return {LHCI.LighthouseRc}

function loadRcFile(pathToRcFile) {
// Load the JSON and convert all `.` in key names to `:`
// Load file
const contents = fs.readFileSync(pathToRcFile, 'utf8');
const rc = JSON.parse(contents);
const rc = parseFileContentToJSON(pathToRcFile, contents);
// Convert all `.` in key names to `:`
recursivelyReplaceDotInKeyName(rc);

@@ -60,2 +68,17 @@ return rc;

/**
* Parse file content to JSON.
* @param {string} pathToRcFile
* @param {string} contents
* @return {LHCI.LighthouseRc}
*/
function parseFileContentToJSON(pathToRcFile, contents) {
// Check if file path ends in yaml or yml
if (YAML_FILE_EXTENSION_REGEX.test(pathToRcFile)) {
// Parse yaml content to JSON
return yaml.safeLoad(contents);
}
return JSON.parse(contents);
}
/**
* @param {string} dir

@@ -62,0 +85,0 @@ * @return {string|undefined}

@@ -39,7 +39,8 @@ /**

*/
function saveLHR(lhr) {
const filename = `lhr-${Date.now()}.json`;
const filePath = path.join(LHCI_DIR, filename);
function saveLHR(lhr, baseDir = LHCI_DIR) {
const baseFilename = `lhr-${Date.now()}`;
const basePath = path.join(baseDir, baseFilename);
ensureDirectoryExists();
fs.writeFileSync(filePath, lhr);
fs.writeFileSync(`${basePath}.json`, lhr);
fs.writeFileSync(`${basePath}.html`, getHTMLReportForLHR(JSON.parse(lhr)));
}

@@ -46,0 +47,0 @@

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