modernizing / lemonj

A CSS/LESS/SCSS analysis, bad smell check and auto-refactor tools. 一个面向 CSS/LESS/SCSS 的分析、坏味道检查和自动化重构工具。
MIT License
140 stars 8 forks source link

运行分析的时候报错 #4

Open tbswang opened 2 years ago

tbswang commented 2 years ago

现象:在运行分析命令是报错了,报错信息没什么有用的,尝试了项目中是其他目录,也是同样的报错

lemonj analysis src      
Code Smell:  {
  colors: 0,
  importants: 0,
  issues: 0,
  mediaQueries: 0,
  absolute: 0,
  oddWidth: 0
}
internal/fs/utils.js:793
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Object.writeFileSync (fs.js:1517:5)
    at analysisDir (/Users/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/lemonj/dist/cli.js:31271:15)
    at Command2.<anonymous> (/Users/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/lemonj/dist/cli.js:31491:3)
    at Command2.listener [as _actionHandler] (/Users/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/lemonj/dist/cli.js:258:33)
    at Command2._parseCommand (/Users/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/lemonj/dist/cli.js:555:16)
    at Command2._dispatchSubcommand (/Users/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/lemonj/dist/cli.js:518:20)
    at Command2._parseCommand (/Users/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/lemonj/dist/cli.js:527:14)
    at Command2.parse (/Users/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/lemonj/dist/cli.js:424:12)
    at Object.<anonymous> (/Users/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/lemonj/dist/cli.js:31498:9)
    at Module._compile (internal/modules/cjs/loader.js:1072:14) {
  code: 'ERR_INVALID_ARG_TYPE'
}

版本: 0.2.0

css版本: scss

phodal commented 2 years ago

定位到问题了:

https://github.com/modernizing/lemonj/blob/68e1bc288d0aa338f70a7a62f9c85197269a04a8/src/Analysis.ts#L64-L68

这里生成判断值为 0 的时候,返回的是个 undefined,所以就挂了。

有兴趣来个 pr 吗?

tbswang commented 2 years ago

定位到问题了:

https://github.com/modernizing/lemonj/blob/68e1bc288d0aa338f70a7a62f9c85197269a04a8/src/Analysis.ts#L64-L68

这里生成判断值为 0 的时候,返回的是个 undefined,所以就挂了。

有兴趣来个 pr 吗?

多谢,我试试