mirror of
https://github.com/gradle/wrapper-validation-action
synced 2024-11-23 17:22:01 +00:00
Walk the dir tree instead of the git tree
In order to support shallow checkouts, because nodegit doesn't play well on CI Signed-off-by: Paul Merlin <paul@gradle.com>
This commit is contained in:
parent
94a3288680
commit
e0653151c5
4 changed files with 433 additions and 21150 deletions
20826
dist/index.js
vendored
20826
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
705
package-lock.json
generated
705
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -26,8 +26,6 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.0",
|
||||
"@types/nodegit": "^0.26.0",
|
||||
"nodegit": "^0.26.3",
|
||||
"typed-rest-client": "^1.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
46
src/find.ts
46
src/find.ts
|
@ -1,27 +1,25 @@
|
|||
import {Repository, Commit, Tree, TreeEntry} from 'nodegit'
|
||||
import * as util from 'util'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
|
||||
export async function findWrapperJars(gitRepoPath: string): Promise<string[]> {
|
||||
const repo: Repository = await Repository.open(gitRepoPath)
|
||||
const commit: Commit = await repo.getHeadCommit()
|
||||
const tree: Tree = await commit.getTree()
|
||||
const walker = tree.walk()
|
||||
const readdir = util.promisify(fs.readdir)
|
||||
|
||||
const prom: Promise<string[]> = new Promise((resolve, reject) => {
|
||||
const wrapperJars: string[] = []
|
||||
|
||||
walker.on('entry', (entry: TreeEntry) => {
|
||||
const path = entry.path()
|
||||
if (path.endsWith('gradle-wrapper.jar')) {
|
||||
wrapperJars.push(path)
|
||||
}
|
||||
})
|
||||
walker.on('error', error => {
|
||||
reject(error)
|
||||
})
|
||||
walker.on('end', () => {
|
||||
resolve(wrapperJars)
|
||||
})
|
||||
})
|
||||
walker.start()
|
||||
return prom
|
||||
export async function findWrapperJars(baseDir: string): Promise<string[]> {
|
||||
const files = await recursivelyListFiles(baseDir)
|
||||
return files
|
||||
.filter(file => file.endsWith('gradle-wrapper.jar'))
|
||||
.map(wrapperJar => path.relative(baseDir, wrapperJar))
|
||||
}
|
||||
|
||||
async function recursivelyListFiles(baseDir: string): Promise<string[]> {
|
||||
const childrenNames = await readdir(baseDir)
|
||||
const childrenPaths = await Promise.all(
|
||||
childrenNames.map(async childName => {
|
||||
const childPath = path.resolve(baseDir, childName)
|
||||
return fs.lstatSync(childPath).isDirectory()
|
||||
? recursivelyListFiles(childPath)
|
||||
: new Promise(resolve => resolve([childPath]))
|
||||
})
|
||||
)
|
||||
return Array.prototype.concat(...childrenPaths)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue