New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

github-codeowners-parser

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

github-codeowners-parser

Antlr4 generated CODEOWNERS parser

latest
Source
npmnpm
Version
1.0.7
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

Description

github-codeowners-parser is a robust npm package tailored for parsing and handling GitHub CODEOWNERS files. Built atop the power of ANTLR4, this package provides functionality to read, parse, and manage the ownership rules defined in a CODEOWNERS file.

Features

  • Parse GitHub CODEOWNERS files with precision.
  • Efficiently manage paths and their associated owners.
  • Advanced string matching capabilities with metric LCS (Longest Common Substring).

Installation

You can install the package via npm:

npm install github-codeowners-parser

Usage

Here's a quick start guide:

  • Import the parser

    import { AddLineVisitor } from 'github-codeowners-parser';
    
  • Instantiate the parser with your input string and the new line you want to add

    const input = `
    # Comment
    /path/to/some/file.js @user1
    /path/to/other/file.js @user2
    `;
    
    const newLine = "/path/to/new/file.js @user3";
    
    const visitor = new AddLineVisitor(input, newLine);
    
  • Process the input and retrieve the updated content

    const processedContent = visitor.visitFile(/* Pass your parsed FileContext here */);
    console.log(processedContent);
    

API Overview

AddLineVisitor

  • Constructor:

    Takes in the original content of the CODEOWNERS file and the new line that you want to insert.

    new AddLineVisitor(input: string, newLine: string)
    
  • Methods:

    • visitFile(ctx: FileContext): string:
      • Processes the file and inserts the new line at the appropriate location.
      • Returns the updated content of the CODEOWNERS file.

Utility Functions:

  • lcsLength(s1: string, s2: string): Returns the length of the longest common substring of two strings.

  • metriclcs(s1: string, s2: string): Provides a metric measure for LCS, useful for string similarity comparisons.

Contributions

If you'd like to contribute to this project or report an issue, please open an issue on our GitHub repository.

License

This package is licensed under the MIT License.

Keywords

antlr4

FAQs

Package last updated on 09 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts