This repository has been archived by the owner on May 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
49 lines (40 loc) · 1.44 KB
/
index.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* YI Mirrorless Firmware Tools
* Author: Mario Guggenberger <mg@protyposis.net>
* Licensed under the GPLv3
*/
'use strict';
const path = require('path');
const firmware = require('./firmware');
if (process.argv.length <= 3) {
console.log('usage: npm run [unpack|repack|flipregion|test] <inputfile>');
console.log(' unpack: unpacks a firmware file into its sections');
console.log(' repack: repacks an unpacked firmware into a flashable firmware file');
console.log(' flipregion: changes the region of a firmware file between CN and INT');
console.log(' test: unpacks and repacks a firmware file and compares input to output to validate everything working correctly');
console.error('Arguments missing');
return;
}
const command = process.argv[2];
const inputFileName = process.argv[3];
const outputDirectoryName = path.dirname(inputFileName);
try {
switch (command) {
case 'unpack':
firmware.unpack(inputFileName, outputDirectoryName);
break;
case 'repack':
firmware.repack(inputFileName, outputDirectoryName);
break;
case 'flipregion':
firmware.flipRegion(inputFileName, outputDirectoryName);
break;
case 'test':
firmware.test(inputFileName, outputDirectoryName);
break;
default:
console.error(`Unknown command: ${command}`);
}
} catch (error) {
console.error(error);
}