Skip to content

Commit

Permalink
CI: Add unit tests for web-portals
Browse files Browse the repository at this point in the history
  • Loading branch information
ivvist committed Jan 11, 2024
1 parent 013c51e commit f90f70d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
17 changes: 8 additions & 9 deletions checkSources.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ const getSourceFiles = function (dir, ignore, files_) {
}

const detectLanguage = function (ignore) {
let sourceFiles = getSourceFiles('.', ignore)
if (fs.existsSync('go.mod')) return "go"
sourceFiles.forEach(file => {
if (path.extname(file) === ".go") return "go"
})
sourceFiles.forEach(file => {
if (path.extname(file) === ".js") return "node_js"
})
return "unknown"
if (fs.existsSync('go.mod')) return "go"
let sourceFiles = getSourceFiles('.', ignore)
for (const file of sourceFiles) {
if (path.extname(file) === ".go") return "go"
if (/\.[jt]sx?/.test(path.extname(file))) return "node_js"
}
return "unknown"
}


const getFirstComment = function (file) {
let content = fs.readFileSync(file, 'utf8')
let m = content.match(/^(\s|\/\/[^\n]*\n|\/\*([^*]|\*(?!\/))*\*\/)*/)
Expand Down
17 changes: 8 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ const getSourceFiles = function (dir, ignore, files_) {
}

const detectLanguage = function (ignore) {
let sourceFiles = getSourceFiles('.', ignore)
if (fs.existsSync('go.mod')) return "go"
sourceFiles.forEach(file => {
if (path.extname(file) === ".go") return "go"
})
sourceFiles.forEach(file => {
if (path.extname(file) === ".js") return "node_js"
})
return "unknown"
if (fs.existsSync('go.mod')) return "go"
let sourceFiles = getSourceFiles('.', ignore)
for (const file of sourceFiles) {
if (path.extname(file) === ".go") return "go"
if (/\.[jt]sx?/.test(path.extname(file))) return "node_js"
}
return "unknown"
}


const getFirstComment = function (file) {
let content = fs.readFileSync(file, 'utf8')
let m = content.match(/^(\s|\/\/[^\n]*\n|\/\*([^*]|\*(?!\/))*\*\/)*/)
Expand Down

0 comments on commit f90f70d

Please sign in to comment.