怎样检察一个 js, ts 文件模块的依靠树
近来接办一个他人的页面,代码非常缭乱与复杂,当我在增添功用时,发明我增加的模块与原有的模块有争执,但不晓得谁人原有的模块在什么位置,就得随处找。
但发明这类体式格局太愚笨了,网上也没有找到响应的东西,干脆我就本身写了一个东西。
项目地点:sdep。
装置
npm install sdep -g
运用
sdep [options] <file>
经常使用命令行参数
-
-q, --query <query>
: 查找某个模块的依靠链(如:-q react
) -
-r, --regular
: 把query
看成正则来婚配(如:-q 'react|react-dom' -r
) -
-i, --ignore
: 不显现node_modules
里的文件
运用的第三方库
例子
检察一个文件的依靠构造
sdep example/index.js
example/index.js
├ example/css/css.css
├ example/css/scss.scss
├ example/css/less.less
├ example/jsx.jsx
| ├ node_modules/react/index.js
| | ├ node_modules/react/cjs/react.production.min.js
| | | └ node_modules/object-assign/index.js
| | └ node_modules/react/cjs/react.development.js
| | ├ node_modules/object-assign/index.js
| | └ node_modules/prop-types/checkPropTypes.js
| | └ node_modules/prop-types/lib/ReactPropTypesSecret.js
| ├ node_modules/react-dom/index.js
| | ├ node_modules/react-dom/cjs/react-dom.production.min.js
| | | ├ node_modules/react/index.js
| | | | ├ node_modules/react/cjs/react.production.min.js
| | | | | └ node_modules/object-assign/index.js
| | | | └ node_modules/react/cjs/react.development.js
| | | | ├ node_modules/object-assign/index.js
| | | | └ node_modules/prop-types/checkPropTypes.js
| | | | └ node_modules/prop-types/lib/ReactPropTypesSecret.js
| | | ├ node_modules/object-assign/index.js
| | | └ node_modules/scheduler/index.js
| | | ├ node_modules/scheduler/cjs/scheduler.production.min.js
| | | └ node_modules/scheduler/cjs/scheduler.development.js
| | └ node_modules/react-dom/cjs/react-dom.development.js
| | ├ node_modules/react/index.js
| | | ├ node_modules/react/cjs/react.production.min.js
| | | | └ node_modules/object-assign/index.js
| | | └ node_modules/react/cjs/react.development.js
| | | ├ node_modules/object-assign/index.js
| | | └ node_modules/prop-types/checkPropTypes.js
| | | └ node_modules/prop-types/lib/ReactPropTypesSecret.js
| | ├ node_modules/object-assign/index.js
| | ├ node_modules/prop-types/checkPropTypes.js
| | | └ node_modules/prop-types/lib/ReactPropTypesSecret.js
| | ├ node_modules/scheduler/index.js
| | | ├ node_modules/scheduler/cjs/scheduler.production.min.js
| | | └ node_modules/scheduler/cjs/scheduler.development.js
| | └ node_modules/scheduler/tracing.js
| | ├ node_modules/scheduler/cjs/scheduler-tracing.production.min.js
| | └ node_modules/scheduler/cjs/scheduler-tracing.development.js
| └ example/wel.jsx
| └ node_modules/react/index.js
| ├ node_modules/react/cjs/react.production.min.js
| | └ node_modules/object-assign/index.js
| └ node_modules/react/cjs/react.development.js
| ├ node_modules/object-assign/index.js
| └ node_modules/prop-types/checkPropTypes.js
| └ node_modules/prop-types/lib/ReactPropTypesSecret.js
└ example/async/index.js
└ example/async/index.css
检察一个文件包括 react
的依靠链
sdep example/index.js -q react
example/index.js
└ example/jsx.jsx
└ node_modules/react/index.js
example/index.js
└ example/jsx.jsx
└ node_modules/react-dom/index.js
example/index.js
└ example/jsx.jsx
└ example/wel.jsx
└ node_modules/react/index.js
检察一个文件包括 less
或 scss
的依靠链
sdep example/index.js -q 'less|scss' -r
example/index.js
└ example/css/scss.scss
example/index.js
└ example/css/less.less
后续
更多博客,检察 https://github.com/senntyou/blogs
版权声明:自在转载-非商用-非衍生-坚持签名(创意同享3.0许可证)