Skip to content
Permalink
Browse files

fix(api): remove last modified (#7)

  • Loading branch information...
dadamssg committed Mar 29, 2019
1 parent c300737 commit 4c11a6b1eebc8b48cbb94d106c9673a988894cbb
Showing with 2 additions and 18 deletions.
  1. +0 −3 readme.md
  2. +2 −15 src/api-route-provider.js
@@ -424,6 +424,3 @@ The above would match:
```
/companies/:companyUnid/employees/:unid/address
```

### Git dates
Hovering over file names will show the last modified date according to git.
@@ -67,7 +67,6 @@ export default function (app, options = {}) {
query: routeFile.query,
params: routeFile.params,
filename: routeFile.filename,
lastModified: routeFile.lastModified,
payload: routeFile.payload,
routeFile: Object.keys(routeFile).length > 0,
headers: getRouteHeaders(options, routeFile)
@@ -150,8 +149,7 @@ export default function (app, options = {}) {
return {
...ref,
startLineNo,
lines,
lastModified: getLastModified(ref.file)
lines
}
})

@@ -194,7 +192,6 @@ export default function (app, options = {}) {
const linesCopy = [...lines]
srcFiles.push({
file,
lastModified: getLastModified(file),
startLineNo: startLine,
lineNo,
lines: linesCopy.splice(startLine - 1, showLines)
@@ -324,7 +321,6 @@ function getFileRoutes (dir) {
route.filename = file
const methods = route.method ? [route.method] : route.methods
route.methods = methods.map(method => method.toLowerCase())
route.lastModified = getLastModified(file)
route.id = getRouteId(route)
route.responses = Array.isArray(route.responses) ? route.responses : []
return route
@@ -369,15 +365,6 @@ function parseFileAndLineNo (str) {
return {file, lineNo}
}

function getLastModified (file) {
try {
const dir = path.dirname(file)
return execSync(`cd ${dir} && git log -1 --date=iso --format=%cD ${file}`).toString().trim()
} catch (e) {
return fs.statSync(file).mtime
}
}

function dirsToArray (dirs) {
return (Array.isArray(dirs) ? dirs : [dirs]).filter(d => !!d)
}
@@ -445,7 +432,7 @@ function findPathInServer (options, path) {
searchResult.split('\n').filter(l => !!l).forEach(result => {
const {file, lineNo} = parseFileAndLineNo(result)
if (!files[file]) {
files[file] = {file, lines: [], lastModified: getLastModified(file)}
files[file] = {file, lines: []}
}
const existingLines = files[file].lines
if (existingLines.findIndex(no => no === lineNo) === -1) {

0 comments on commit 4c11a6b

Please sign in to comment.
You can’t perform that action at this time.