Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): remove last modified #7

Merged
merged 2 commits into from Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions readme.md
Expand Up @@ -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.
17 changes: 2 additions & 15 deletions src/api-route-provider.js
Expand Up @@ -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)
Expand Down Expand Up @@ -150,8 +149,7 @@ export default function (app, options = {}) {
return {
...ref,
startLineNo,
lines,
lastModified: getLastModified(ref.file)
lines
}
})

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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) {
Expand Down