Add helper script

This commit is contained in:
Piotr Rogowski 2023-09-11 11:30:39 +02:00
parent 30b9b09ff1
commit 745f4fb59a
No known key found for this signature in database
GPG Key ID: 4A842D702D9C6F8F
1 changed files with 18 additions and 0 deletions

18
scripts/decompress.js Normal file
View File

@ -0,0 +1,18 @@
const Pako = require('pako');
// get file from command line
const file = process.argv[2];
// read file
const fs = require('fs');
const data = fs.readFileSync(file);
const result = Pako.inflate(data, { to: 'string' });
// write file with suffix .decompressed
const path = require('path');
const basename = path.basename(file);
const extname = path.extname(file);
const filename = basename.slice(0, -extname.length);
const newFile = `${filename}.decompressed${extname}`;
fs.writeFileSync(newFile, result);