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.
Files changed (2) hide show
  1. package/index.js +2 -3
  2. 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 = dirname + `${item}`
11
- const targetFilepath = dirname + fileName + targetExt
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rename-ext",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"