mirror of
https://github.com/sasjs/lint.git
synced 2026-01-11 22:30:06 +00:00
feat(lint): implement v1 with 3 rules - trailing spaces, encoded passwords and Doxygen header
This commit is contained in:
27
src/utils/getProjectRoot.ts
Normal file
27
src/utils/getProjectRoot.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import path from 'path'
|
||||
import { fileExists } from '@sasjs/utils/file'
|
||||
|
||||
export async function getProjectRoot() {
|
||||
let root = ''
|
||||
let rootFound = false
|
||||
let i = 1
|
||||
let currentLocation = process.cwd()
|
||||
|
||||
const maxLevels = currentLocation.split(path.sep).length
|
||||
|
||||
while (i <= maxLevels && !rootFound) {
|
||||
const isRoot = await fileExists(path.join(currentLocation, '.sasjslint'))
|
||||
|
||||
if (isRoot) {
|
||||
rootFound = true
|
||||
root = currentLocation
|
||||
|
||||
break
|
||||
} else {
|
||||
currentLocation = path.join(currentLocation, '..')
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
return root
|
||||
}
|
||||
Reference in New Issue
Block a user