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

linkinator

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkinator - npm Package Compare versions

Comparing version 4.0.3 to 4.1.0

46

build/src/config.js
import { promises as fs } from 'fs';
import path from 'path';
export async function getConfig(flags) {
// check to see if a config file path was passed
const configPath = flags.config || 'linkinator.config.json';
let configData;
try {
configData = await fs.readFile(configPath, { encoding: 'utf8' });
}
catch (e) {
if (flags.config) {
console.error(`Unable to find config file ${flags.config}`);
throw e;
}
}
let config = {};
if (configData) {
config = JSON.parse(configData);
if (flags.config) {
config = await parseConfigFile(configPath);
}

@@ -34,2 +25,33 @@ // `meow` is set up to pass boolean flags as `undefined` if not passed.

}
const validConfigExtensions = ['.js', '.mjs', '.cjs', '.json'];
async function parseConfigFile(configPath) {
const typeOfConfig = getTypeOfConfig(configPath);
switch (typeOfConfig) {
case '.json':
return readJsonConfigFile(configPath);
case '.js':
case '.mjs':
case '.cjs':
return importConfigFile(configPath);
}
throw new Error(`Config file ${configPath} is invalid`);
}
function getTypeOfConfig(configPath) {
// Returning json in case file doesn't have an extension for backward compatibility
const configExtension = path.extname(configPath) || '.json';
if (validConfigExtensions.includes(configExtension)) {
return configExtension;
}
throw new Error(`Config file should be either of extensions ${validConfigExtensions.join(',')}`);
}
async function importConfigFile(configPath) {
const config = (await import(`file://${path.resolve(process.cwd(), configPath)}`)).default;
return config;
}
async function readJsonConfigFile(configPath) {
const configFileContents = await fs.readFile(configPath, {
encoding: 'utf-8',
});
return JSON.parse(configFileContents);
}
//# sourceMappingURL=config.js.map
{
"name": "linkinator",
"description": "Find broken links, missing images, etc in your HTML. Scurry around your site and find all those broken links.",
"version": "4.0.3",
"version": "4.1.0",
"license": "MIT",

@@ -42,3 +42,3 @@ "repository": "JustinBeckwith/linkinator",

"@types/mime": "^3.0.0",
"@types/mocha": "^9.0.0",
"@types/mocha": "^10.0.0",
"@types/node": "^16.11.7",

@@ -45,0 +45,0 @@ "@types/server-destroy": "^1.0.1",

Sorry, the diff of this file is not supported yet

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