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
20830
dist/index.js
vendored
20830
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",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.0",
|
||||||
"@types/nodegit": "^0.26.0",
|
|
||||||
"nodegit": "^0.26.3",
|
|
||||||
"typed-rest-client": "^1.7.1"
|
"typed-rest-client": "^1.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"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 readdir = util.promisify(fs.readdir)
|
||||||
const repo: Repository = await Repository.open(gitRepoPath)
|
|
||||||
const commit: Commit = await repo.getHeadCommit()
|
|
||||||
const tree: Tree = await commit.getTree()
|
|
||||||
const walker = tree.walk()
|
|
||||||
|
|
||||||
const prom: Promise<string[]> = new Promise((resolve, reject) => {
|
export async function findWrapperJars(baseDir: string): Promise<string[]> {
|
||||||
const wrapperJars: string[] = []
|
const files = await recursivelyListFiles(baseDir)
|
||||||
|
return files
|
||||||
walker.on('entry', (entry: TreeEntry) => {
|
.filter(file => file.endsWith('gradle-wrapper.jar'))
|
||||||
const path = entry.path()
|
.map(wrapperJar => path.relative(baseDir, wrapperJar))
|
||||||
if (path.endsWith('gradle-wrapper.jar')) {
|
}
|
||||||
wrapperJars.push(path)
|
|
||||||
}
|
async function recursivelyListFiles(baseDir: string): Promise<string[]> {
|
||||||
})
|
const childrenNames = await readdir(baseDir)
|
||||||
walker.on('error', error => {
|
const childrenPaths = await Promise.all(
|
||||||
reject(error)
|
childrenNames.map(async childName => {
|
||||||
})
|
const childPath = path.resolve(baseDir, childName)
|
||||||
walker.on('end', () => {
|
return fs.lstatSync(childPath).isDirectory()
|
||||||
resolve(wrapperJars)
|
? recursivelyListFiles(childPath)
|
||||||
})
|
: new Promise(resolve => resolve([childPath]))
|
||||||
})
|
})
|
||||||
walker.start()
|
)
|
||||||
return prom
|
return Array.prototype.concat(...childrenPaths)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue