Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/harmony/clone-jdharmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const os = require('os')
const path = require('path')
const { remove, ensureDir } = require('fs-extra')
const fs = require('fs')
const fse = require('fs-extra')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

重复导入 fs-extra 模块

第4行已经从 fs-extra 导入了 removeensureDir 方法。建议移除重复的导入,直接使用已导入的 remove 方法。

建议应用以下修改:

-const fse = require('fs-extra')

然后在第26行使用:

-  await fse.remove(path.join(__dirname, '../../packages/JDHarmony/.git'))
+  await remove(path.join(__dirname, '../../packages/JDHarmony/.git'))

Committable suggestion skipped: line range outside the PR's diff.

const args = process.argv.splice(2)

const home = os.homedir()
Expand All @@ -22,6 +23,7 @@ async function cloneJdHarmony() {
console.log(`Clone ${platform}, branch: ${branch}`)

await git.clone(remote, ['-b', branch, '--depth', '1'])
await fse.remove(path.join(__dirname, '../../packages/JDHarmony/.git'))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

建议添加错误处理以提高代码健壮性

代码中已经包含了基本的日志记录,但缺少对 fse.remove 操作的错误处理。建议使用 try-catch 块包装删除操作:

try {
  await fse.remove(path.join(__dirname, '../../packages/JDHarmony/.git'))
  console.log('Git 目录删除成功')
} catch (error) {
  console.error('删除 .git 目录时发生错误:', error)
  throw error
}
🔗 Analysis chain

验证 .git 目录的删除操作

为确保 .git 目录被正确删除,建议添加错误处理和日志记录。

运行以下脚本验证删除操作:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证 .git 目录是否被正确删除

# 测试:检查是否存在 .git 目录
fd -H -t d '^\.git$' packages/

Length of output: 32


Script:

#!/bin/bash
# 检查目录结构和文件权限
ls -la packages/JDHarmony/

# 检查是否有相关的错误处理代码
rg -A 3 "fse.remove.*\.git" scripts/

# 检查是否有相关的日志记录
rg "console\.(log|error)" scripts/harmony/clone-jdharmony.js

Length of output: 737


console.log(`Clone completed successfully.`)
// 修改文件夹名称
Expand Down