Skip to content

Commit

Permalink
fix: fix createdAt calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
dword-design committed Mar 18, 2021
1 parent 575cac9 commit cd97d61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"test": "base test"
},
"dependencies": {
"@dword-design/functions": "^1.2.2",
"simple-git": "^2.37.0"
},
"devDependencies": {
"@dword-design/base": "^7.9.0",
"@dword-design/functions": "^1.2.2",
"@dword-design/puppeteer": "^3.0.1",
"@dword-design/tester": "^1.2.1",
"@dword-design/tester-plugin-puppeteer": "^1.0.3",
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { last, property } from '@dword-design/functions'
import P from 'path'
import simpleGit from 'simple-git'

Expand All @@ -14,7 +15,9 @@ export default options => {
file: P.join(database.dir, `${file.path}${file.extension}`),
})
file[options.createdAtName] =
log.all.length > 0 ? new Date(log.all[0].date) : file.createdAt
log.all.length > 0
? new Date(log.all |> last |> property('date'))
: file.createdAt
file[options.updatedAtName] =
log.latest === null ? file.updatedAt : new Date(log.latest.date)
},
Expand Down
9 changes: 6 additions & 3 deletions src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { endent } from '@dword-design/functions'
import { endent, last, property } from '@dword-design/functions'
import tester from '@dword-design/tester'
import testerPluginPuppeteer from '@dword-design/tester-plugin-puppeteer'
import packageName from 'depcheck-package-name'
import execa from 'execa'
import { stat } from 'fs-extra'
import { outputFile, stat } from 'fs-extra'
import { Builder, Nuxt } from 'nuxt'
import outputFiles from 'output-files'
import P from 'path'
Expand Down Expand Up @@ -146,9 +146,12 @@ export default tester(
})
await execa.command('git add .')
await execa.command('git commit -m init')
await outputFile(P.join('content', 'home.md'), 'foo')
await execa.command('git add .')
await execa.command('git commit -m update')
const git = simpleGit()
const log = await git.log({ file: P.join('content', 'home.md') })
const createdAt = new Date(log.all[0].date)
const createdAt = new Date(log.all |> last |> property('date'))
const updatedAt = new Date(log.latest.date)
const nuxt = new Nuxt({
createRequire: 'native',
Expand Down

0 comments on commit cd97d61

Please sign in to comment.