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

get-dir-code

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-dir-code

可用于合并项目代码为一个长字符串,同时计算总行数

latest
Source
npmnpm
Version
1.2.4
Version published
Maintainers
1
Created
Source

目录代码提取与合并工具

可用于合并项目代码为一个长字符串,同时计算总行数

安装

npm i get-dir-code

合并代码

import { getCode } from 'get-dir-code'

// 需要提取代码的根目录
const targetDir = 'D:/MyCode/Project01'
// 获取合并结果
const codeData = getCode(targetDir)
// 合并后的代码字符串
const codeStr = codeData.code
// 合并后的代码总行数
const codeLine = codeData.line

筛选文件后缀

const exts = ['.js', '.ts', '.css', '.sass', '.scss', '.html', '.sql', '.json']
const codeData = getCode(targetDir, { exts })

排除项

支持 .gitignore 规则,详见 ignore

const exclude = ['package-lock.json', 'package.json', 'LICENSE', '.gitignore']
const codeData = getCode(targetDir, { exclude })

禁用日志输出

const codeData = getCode(targetDir, { log: false })

递归获取文件列表

import { getFiles } from 'get-dir-code'

const rootDir = 'D:/MyCode/Project01'
const files = getFiles(rootDir)

// 和 getCode 方法一致,支持筛选文件后缀和设置排除项
// getFiles(rootDir, ['.ts', '.js', '.html'])
// getFiles(rootDir, ['.ts', '.js', '.html'], ['package.json'])

项目信息

  • 作者:爱优鹏科技
  • 公众号:爱优鹏网络科技
  • 开发日期:2024 年 2 月 28 日

Keywords

dir

FAQs

Package last updated on 08 May 2024

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