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

freshlinks

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

freshlinks - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

lib/suggest-path.d.ts

25

lib/cli.js

@@ -31,2 +31,5 @@ #!/usr/bin/env node

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -36,9 +39,21 @@ const parse_markdown_links_1 = require("./parse-markdown-links");

const validate_link_1 = require("./validate-link");
const suggest_path_1 = require("./suggest-path");
const yargs = __importStar(require("yargs"));
const process = __importStar(require("process"));
const chalk_1 = __importDefault(require("chalk"));
function run() {
return __awaiter(this, void 0, void 0, function* () {
const args = yargs.argv._;
const cmdLineArguments = yargs.options({
suggestions: { type: 'boolean', default: true }
}).argv;
const files = cmdLineArguments._;
let exitCode = 0;
for (const file of args) {
let possibleLinkDestinations;
if (cmdLineArguments.suggestions) {
possibleLinkDestinations = yield suggest_path_1.gitLsFiles('.');
}
else {
possibleLinkDestinations = [];
}
for (const file of files) {
try {

@@ -53,2 +68,8 @@ const links = yield parse_markdown_links_1.parse_markdown_links_from_file(file);

console.log(format_1.formatInvalidMarkdownLink(link));
if (cmdLineArguments.suggestions) {
const [suggestion, distance] = suggest_path_1.suggestPath(link.sourceFile, link.link, possibleLinkDestinations);
if (distance <= suggest_path_1.SUGGEST_MIN_DISTANCE) {
console.log(`Perhaps you meant: ${chalk_1.default.blue(suggestion)} ${distance}`);
}
}
}

@@ -55,0 +76,0 @@ }

4

lib/format.js

@@ -15,6 +15,6 @@ "use strict";

const errorString = `
${chalk_1.default.underline(`${link.sourceFile}:${link.startLine}`)}
${chalk_1.default.bold.red('Error')} Could not resolve link: ${chalk_1.default.yellow(link.link)}`;
${chalk_1.default.underline(`${link.sourceFile}:${link.startLine}`)}
${chalk_1.default.bold.red('Error')} Could not resolve link: ${chalk_1.default.yellow(link.link)}`;
return errorString;
}
exports.formatInvalidMarkdownLink = formatInvalidMarkdownLink;

@@ -30,6 +30,7 @@ "use strict";

}
const decodedLinkPath = decodeURIComponent(linkPath);
const sourceFile = path_1.dirname(link.sourceFile);
// don't test absolute paths
if (!linkPath.startsWith('/')) {
const joinedLinkPath = path_1.join(sourceFile, linkPath);
if (!decodedLinkPath.startsWith('/')) {
const joinedLinkPath = path_1.join(sourceFile, decodedLinkPath);
try {

@@ -36,0 +37,0 @@ yield fs_1.promises.access(joinedLinkPath);

{
"name": "freshlinks",
"version": "0.0.1",
"version": "0.0.2",
"private": false,

@@ -5,0 +5,0 @@ "description": "Freshlinks",

@@ -20,7 +20,9 @@ import {MarkdownLink} from './parse-markdown-links'

const decodedLinkPath = decodeURIComponent(linkPath)
const sourceFile = dirname(link.sourceFile)
// don't test absolute paths
if (!linkPath.startsWith('/')) {
const joinedLinkPath = join(sourceFile, linkPath)
if (!decodedLinkPath.startsWith('/')) {
const joinedLinkPath = join(sourceFile, decodedLinkPath)
try {

@@ -27,0 +29,0 @@ await fs.access(joinedLinkPath)

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