Skip to content

Commit 118e723

Browse files
committed
Get filename using path basename
1 parent 41337c5 commit 118e723

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

fs-extra/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const targetFileName = (source, basedir) => {
2828
const year = date.getFullYear()
2929
const dir = `${year}-${padZero}${month}-${day}`
3030

31+
const fname = path.basename(source)
3132
// 2020-01-11/access.log
32-
const target = `${basedir}/${dir}/${source}`
33+
const target = `${basedir}/${dir}/${fname}`
3334
return target
3435
}
3536
```

fs-extra/src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import fs from 'fs-extra'
2+
import path from 'path'
23

34
const move = (source, target) => {
4-
console.log(`Start moving ${source} to ${target}`)
5+
console.log(`Start moving ${fname} to ${target}`)
56
try {
67
fs.moveSync(source, target, { override: true })
78
} catch(e) {
@@ -20,8 +21,9 @@ const targetFileName = (source, basedir) => {
2021
const year = date.getFullYear()
2122
const dir = `${year}-${padZero}${month}-${day}`
2223

24+
const fname = path.basename(source)
2325
// 2020-01-11/access.log
24-
const target = `${basedir}/${dir}/${source}`
26+
const target = `${basedir}/${dir}/${fname}`
2527
return target
2628
}
2729

0 commit comments

Comments
 (0)