-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2022 Daniel Imms <http://www.growingwiththeweb.com> | ||
* Released under MIT license. See LICENSE in the project root for details. | ||
*/ | ||
|
||
const decoder = require('..'); | ||
const fs = require('fs/promises'); | ||
const { extname } = require('path'); | ||
|
||
async function decode(file) { | ||
if (extname(file) !== '.tga') { | ||
throw new Error('File must end with .tga'); | ||
} | ||
const originalData = await fs.readFile(file); | ||
const decoded = await decoder.decodeTga(originalData); | ||
console.log(`Decoded "${file}":`, decoded); | ||
} | ||
|
||
if (process.argv.length < 3) { | ||
console.error('Provide a file as the first argument'); | ||
process.exit(1); | ||
} | ||
|
||
decode(process.argv[2]); |