npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

code-merge-markdown

v1.0.4

Published

npm package for merging code files into a markdown file

Downloads

22

Readme

code-merge-markdown

code-merge-markdown is a simple Node.js tool for merging code files from a specified directory into a single markdown file. Each code file is wrapped in a markdown code block, with an appropriate language identifier based on the file extension.

Features

  • Merge code files from a directory into a single markdown file
  • Supports filtering by file extensions
  • Option to include file names as headers in the merged markdown file
  • Recursive directory traversal
  • Exclude specific files or directories

Installation

To install code-merge-markdown, you need to have Node.js and npm installed. You can install the package globally using npm:

npm install -g code-merge-markdown

Usage

To use code-merge-markdown, you can run it from the command line with the following options:

code-merge-markdown -i <inputDir> -o <outputFile> [options]

Options

  • -i, --inputDir <inputDir>: Directory containing the code files to merge (required)
  • -o, --outputFile <outputFile>: Name of the output markdown file (required)
  • -e, --fileExtensions <extensions>: File extensions to include in the merge (default: all files)
  • -f, --includeFileNames: Include file names as headers in the merged markdown file (default: true)
  • -h, --headerLevel <level>: Markdown header level to use for file names (default: 2)
  • -r, --recursive: Merge files from subdirectories recursively (default: false)
  • -x, --excludePatterns <patterns>: Patterns of file names or directories to exclude from the merge (default: none)

Example

To merge all .js and .ts files from the src directory and its subdirectories into a markdown file named merged-code.md:

code-merge-markdown -i ./src -o ./merged-code.md -e js ts -r

Example Output

For example if you have the following files:

src/test
├── file1.ts
├── file2.js
└── parent
    ├── file3.ts
    └── file4.js

The output will be:

## file2.js
console.log('Hello from file2.js');

## file1.ts
console.log('Hello from file1.ts');

## parent/file4.js
console.log('Hello from file4.js');

## parent/file3.ts
console.log('Hello from file3.ts');

Default Exclude Patterns

By default, the tool excludes common directories and files that are not typically part of the source code. You can customize these patterns by providing your own list of exclude patterns using the -x option.

    const defaultExcludePatterns = [
        '**/node_modules/**',    // Node.js
        '**/dist/**',            // Common distribution directory
        '**/build/**',           // Common build directory
        '**/__pycache__/**',     // Python
        '**/.venv/**',           // Python virtual environment
        '**/venv/**',            // Python virtual environment
        '**/.env/**',            // Python virtual environment
        '**/site-packages/**',   // Python packages
        '**/vendor/**',          // PHP
        '**/target/**',          // Java
        '**/bin/**',             // Go
        '**/pkg/**',             // Go
        '**/lib/**',             // Common library directory
        '**/.mvn/**',            // Maven (Java)
        '**/.gradle/**'          // Gradle (Java)
    ];

License

This project is licensed under the MIT License.

Feel free to adjust any sections to better fit your project's specifics, such as the repository URL in the development section.