endef 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/de.js +2 -2
- package/src/de.sh +2 -2
- package/src/en.js +35 -41
- package/src/run.js +2 -2
package/package.json
CHANGED
package/src/de.js
CHANGED
|
@@ -4,8 +4,8 @@ import { resolve } from 'path'
|
|
|
4
4
|
export const deSrc = resolve(__dirname)
|
|
5
5
|
export const curDir = process.cwd()
|
|
6
6
|
|
|
7
|
-
export default function () {
|
|
8
|
-
spawn(`bash`, [`${deSrc}\/de.sh ${curDir}`], {
|
|
7
|
+
export default function (args3) {
|
|
8
|
+
spawn(`bash`, [`${deSrc}\/de.sh ${curDir} ${args3}`], {
|
|
9
9
|
cwd: curDir,
|
|
10
10
|
stdio: 'inherit',
|
|
11
11
|
shell: process.platform === 'win32'
|
package/src/de.sh
CHANGED
|
@@ -13,7 +13,7 @@ process_filename() {
|
|
|
13
13
|
|
|
14
14
|
# 判断新文件名对应的文件是否存在
|
|
15
15
|
if [[ -f "$new_path" ]]; then
|
|
16
|
-
if grep -q "E-SafeNet" "$new_path"; then
|
|
16
|
+
if grep -q "E-SafeNet" "$new_path" || [[ $2 == "over" ]]; then
|
|
17
17
|
rm "$new_path" # 删除包含特定内容的文件
|
|
18
18
|
mv "$file" "$new_path" # 重命名文件
|
|
19
19
|
echo "Renamed: $filename -> $new_filename"
|
|
@@ -33,4 +33,4 @@ export -f process_filename
|
|
|
33
33
|
|
|
34
34
|
# 处理文件名并重命名(并行处理)
|
|
35
35
|
find "$directory" -type f -print0 | \
|
|
36
|
-
xargs -0 -P "$(nproc)" -I{} bash -c 'process_filename "$@"' _ {}
|
|
36
|
+
xargs -0 -P "$(nproc)" -I{} bash -c 'process_filename "$@"' _ {} "$2"
|
package/src/en.js
CHANGED
|
@@ -1,60 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
3
|
|
|
4
|
-
export default function processFiles(directory) {
|
|
4
|
+
export default function processFiles(directory, fileExtensions, excludedDirectories = []) {
|
|
5
5
|
fs.readdir(directory, (err, files) => {
|
|
6
6
|
if (err) {
|
|
7
|
-
console.error('Error reading directory:', err)
|
|
8
|
-
return
|
|
7
|
+
console.error('Error reading directory:', err);
|
|
8
|
+
return;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
files.forEach(file => {
|
|
12
|
-
const filePath = path.join(directory, file)
|
|
12
|
+
const filePath = path.join(directory, file);
|
|
13
13
|
|
|
14
14
|
fs.stat(filePath, (err, stats) => {
|
|
15
15
|
if (err) {
|
|
16
|
-
console.error('Error stating file:', err)
|
|
17
|
-
return
|
|
16
|
+
console.error('Error stating file:', err);
|
|
17
|
+
return;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (stats.isDirectory()) {
|
|
21
|
-
|
|
21
|
+
// 排除指定的文件夹
|
|
22
|
+
if (excludedDirectories.includes(file)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
processFiles(filePath, fileExtensions, excludedDirectories); // 递归处理子目录
|
|
22
26
|
} else {
|
|
23
27
|
// 处理文件
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const tempFilePath = filePath + '._$_foobar'
|
|
31
|
-
|
|
32
|
-
// 写入临时文件
|
|
33
|
-
fs.writeFile(tempFilePath, data, 'utf8', err => {
|
|
28
|
+
const fileExtension = path.extname(filePath);
|
|
29
|
+
// 检查文件后缀名是否符合要求
|
|
30
|
+
if (fileExtensions.includes(fileExtension)) {
|
|
31
|
+
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
34
32
|
if (err) {
|
|
35
|
-
console.error('Error
|
|
36
|
-
return
|
|
33
|
+
console.error('Error reading file:', err);
|
|
34
|
+
return;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
const tempFilePath = filePath + '._$_foobar';
|
|
38
|
+
|
|
39
|
+
// 写入临时文件
|
|
40
|
+
fs.writeFile(tempFilePath, data, 'utf8', err => {
|
|
41
|
+
if (err) {
|
|
42
|
+
console.error('Error writing temp file:', err);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// } else {
|
|
46
|
-
// // console.log('Temp file deleted:', filePath);
|
|
47
|
-
// /*fs.rename(tempFilePath, filePath, (err) => {
|
|
48
|
-
// if(!err) {
|
|
49
|
-
// console.log(newName + ' 已重命名!')
|
|
50
|
-
// }
|
|
51
|
-
// })*/
|
|
52
|
-
// }
|
|
53
|
-
// })
|
|
54
|
-
})
|
|
55
|
-
})
|
|
46
|
+
console.log('Temp file written:', tempFilePath);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
56
50
|
}
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
package/src/run.js
CHANGED
|
@@ -3,10 +3,10 @@ import deF from './de'
|
|
|
3
3
|
|
|
4
4
|
export async function run(args) {
|
|
5
5
|
if (args[2] === 'en') {
|
|
6
|
-
enF(process.cwd())
|
|
6
|
+
enF(process.cwd(), ['.js', '.ts', '.vue', '.md'], ['node_modules', '.git'])
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
if (args[2] === 'de') {
|
|
10
|
-
deF()
|
|
10
|
+
deF(args[3] || 'none')
|
|
11
11
|
}
|
|
12
12
|
}
|