From 2770dcd319100afd7244c8b726bf64cce4014956 Mon Sep 17 00:00:00 2001 From: wangxudong13804 Date: Tue, 20 Feb 2024 18:06:59 +0800 Subject: [PATCH] fix: some blank file error --- bin/index.js | 11 ++++++----- package.json | 2 +- tests/blank.js | 0 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 tests/blank.js diff --git a/bin/index.js b/bin/index.js index 27f197f..b5d3b91 100644 --- a/bin/index.js +++ b/bin/index.js @@ -101,12 +101,13 @@ async function lintFiles(filePaths) { // 统计进行lint的代码行数 let filePathsStr = fileGroups[fileType].join(' '); // console.log(fileGroups[fileType]) - let stdout = execSync(`cloc --json ${filePathsStr}`).toString(); - // console.log(stdout) + // let stdout = execSync(`cloc --json ${filePathsStr}`).toString(); + // console.log('wow\n', JSON.parse(stdout)) - totalBlankLines += JSON.parse(stdout)['SUM']['blank'] - totalCommentLines += JSON.parse(stdout)['SUM']['comment'] - totalCodeLines += JSON.parse(stdout)['SUM']['code'] + let stdout = execSync(`cloc --json ${filePathsStr}`).toString(); + totalBlankLines += JSON.parse(stdout)['SUM']?.blank || 0 + totalCommentLines += JSON.parse(stdout)['SUM']?.comment || 0 + totalCodeLines += JSON.parse(stdout)['SUM']?.code || 0 } } diff --git a/package.json b/package.json index a57cb12..8340a9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@afuteam/eslint-plugin-fe", - "version": "2.0.5-beta.5", + "version": "2.0.5-beta.6", "description": "AfuTeam ESLint Plugin", "main": "./lib/index.js", "exports": { diff --git a/tests/blank.js b/tests/blank.js new file mode 100644 index 0000000..e69de29