Skip to content

Commit

Permalink
Use globby.stream for finding Smali files
Browse files Browse the repository at this point in the history
niklashigi committed Jan 2, 2021

Verified

This commit was signed with the committer’s verified signature.
niklashigi Niklas Higi
1 parent 65c3af1 commit 07d35a7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tasks/disable-certificate-pinning.ts
Original file line number Diff line number Diff line change
@@ -47,11 +47,12 @@ export default async function disableCertificatePinning(directoryPath: string, t
const directoryPathPosix = directoryPath.split(path.sep).join(path.posix.sep)
const globPattern = path.posix.join(directoryPathPosix, 'smali*/**/*.smali')

const smaliFiles = await globby(globPattern)

let pinningFound = false

for (const filePath of smaliFiles) {
for await (const filePathChunk of globby.stream(globPattern)) {
// Required because Node.js streams are not typed as generics
const filePath = filePathChunk as string

next(`Scanning ${path.basename(filePath)}...`)

let originalContent = await fs.readFile(filePath, 'utf-8')
@@ -108,7 +109,7 @@ export default async function disableCertificatePinning(directoryPath: string, t
patchedContent = patchedContent.replace(/\n/g, '\r\n')
}

await fs.writeFile(filePath, patchedContent)
await fs.writeFile(filePathChunk, patchedContent)
}
}

0 comments on commit 07d35a7

Please sign in to comment.