Skip to content

Commit

Permalink
Throw error when input directory does not contain an apktool.yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
niklashigi committed Apr 17, 2022
1 parent c911d1e commit 62bf931
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path'
import * as fs from 'fs/promises'
import * as fs from './utils/fs'
import parseArgs = require('yargs-parser')
import chalk = require('chalk')
import Listr = require('listr')
Expand Down Expand Up @@ -167,6 +167,14 @@ async function determineTask(inputPath: string) {
if (fileStats.isDirectory()) {
taskFunction = patchApk
skipDecode = true

const apktoolYamlPath = path.join(inputPath, 'apktool.yml')
if (!(await fs.exists(apktoolYamlPath))) {
throw new UserError(
'No "apktool.yml" file found inside the input directory!' +
' Make sure to specify a directory created by "apktool decode".',
)
}
} else {
const inputFileExtension = path.extname(inputPath)

Expand Down
2 changes: 2 additions & 0 deletions src/utils/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export const exists = promisify(fs.exists)
export const unlink = fsp.unlink
export const rename = fsp.rename
export const mkdir = fsp.mkdir
export const rm = fsp.rm
export const stat = fsp.stat

0 comments on commit 62bf931

Please sign in to comment.