Skip to content

Commit

Permalink
Use globby.stream for finding Smali files
Browse files Browse the repository at this point in the history
  • Loading branch information
niklashigi committed Jan 2, 2021
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
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 07d35a7

Please sign in to comment.