forked from callstackincubator/rock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.ts
More file actions
33 lines (31 loc) · 1008 Bytes
/
command.ts
File metadata and controls
33 lines (31 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import path from 'node:path';
import type { PluginApi } from '@rock-js/config';
import { outro, RockError } from '@rock-js/tools';
import { validateElfAlignment } from './validateElfAlignment.js';
const ARGUMENTS = [
{
name: 'binaryPath',
description: 'Path to APK file to validate.',
},
];
export function registerValidateElfAlignmentCommand(api: PluginApi) {
api.registerCommand({
name: 'validate-elf-alignment',
description: 'Validate ELF alignment of shared libraries in an APK.',
args: ARGUMENTS,
action: async (binaryPath: string | undefined) => {
if (!binaryPath) {
throw new RockError(
'Missing APK path. Provide it as an argument.',
);
}
if (path.extname(binaryPath).toLowerCase() !== '.apk') {
throw new RockError(
`Expected an .apk file, got "${path.extname(binaryPath) || 'no extension'}".`,
);
}
await validateElfAlignment(binaryPath);
outro('Success 🎉.');
},
});
}