rename-ext 1.0.0 → 1.0.1
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/index.js +2 -3
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
function renameExt(targetDir, nowExt, targetExt) {
|
2
2
|
const fs = require('fs')
|
3
3
|
const path = require('path')
|
4
|
-
const dirname = __dirname + `/${targetDir}/`
|
5
4
|
const targetFiles = fs.readdirSync(dirname)
|
6
5
|
targetFiles.forEach(item => {
|
7
6
|
const filePath = path.parse(item)
|
8
7
|
const fileName = filePath.name
|
9
8
|
const fileExt = filePath.ext
|
10
|
-
const nowFilePath =
|
11
|
-
const targetFilepath =
|
9
|
+
const nowFilePath = `/${targetDir}/` + `${item}`
|
10
|
+
const targetFilepath = `/${targetDir}/` + fileName + targetExt
|
12
11
|
console.log(nowFilePath, targetFilepath)
|
13
12
|
if (fileExt === nowExt) {
|
14
13
|
fs.renameSync(nowFilePath, targetFilepath)
|