调试器
Depcheck 是一个用于分析项目中的依赖性的工具,用于查看每个依赖性是如何使用的,哪些依赖性是无用的,哪些依赖性是缺失的 package.json。 。 。 .
它是一个原始的港口 调试它使用 缩写 为解析.
安装
用 npm 安装 :
npm install --save-dev @depcheck-rs-node/core
用纱线安装 :
yarn add --dev @depcheck-rs-node/core
或者用生锈来安装 Depcheck-rs cli:
cargo install depcheck-rs-cli
语法支持
Depcheck 不仅承认JavaScript文件中的依赖性,而且支持这些语法:
使用量
USAGE:
depcheck-rs [OPTIONS]
OPTIONS:
-d, --directory <DIRECTORY>
The directory argument is the root directory of your project [default: .]
-h, --help
Print help information
--ignore-bin-package
A flag to indicate if depcheck ignores the packages containing bin entry
--ignore-path <IGNORE_PATH>
Path to a file with patterns describing files to ignore
--ignore-patterns <IGNORE_PATTERNS>
Comma separated patterns describing files or directories to ignore
--ignore_matches <IGNORE_MATCHES>
A comma separated array containing package names to ignore
-q, --quiet
Less output per occurrence
--skip-missing
A flag to indicate if depcheck skips calculation of missing dependencies
-v, --verbose
More output per occurrence
-V, --version
Print version information
API 密码
import {depcheck} from "@depcheck-rs-node/core";
const options = {
ignoreBinPackage: false, // ignore the packages with bin entry
skipMissing: false, // skip calculation of missing dependencies
ignorePatterns: [
// files matching these patterns will be ignored
'sandbox',
'dist',
'bower_components',
],
ignoreMatches: [
// ignore dependencies that matches these globs
'grunt-*',
],
ignorePath: '/path/to/your/.depcheckignore',
};
depcheck('/path/to/your/project', options).then((result) => {
console.log(result.unusedDependencies); // an array containing the unused dependencies
console.log(result.unusedDevDependencies); // an array containing the unused devDependencies
console.log(result.missingDependencies); // a lookup containing the dependencies missing in `package.json` and where they are used
console.log(result.usingDependencies); // a lookup indicating each dependency is used by which files
});
许可证
MIT许可证.