最近接手一个别人的页面,代码很是凌乱与庞杂,当我在增加功能时,发现我添加的模块与原有的模块有冲突,但不知道那个原有的模块在什么位置,就得到处找。
但发现这种方式太笨拙了,网上也没有找到相应的工具,索性我就自己写了一个工具。
项目地址: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
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
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/deepraining/blogs
版权声明:自由转载-非商用-非衍生-保持署名(创意共享 3.0 许可证)