Skip to content

Instantly share code, notes, and snippets.

@gildas-lormeau
Last active September 3, 2023 12:43
Show Gist options
  • Save gildas-lormeau/f05b65a8654587ea89857c0213d809a9 to your computer and use it in GitHub Desktop.
Save gildas-lormeau/f05b65a8654587ea89857c0213d809a9 to your computer and use it in GitHub Desktop.
CLI to transform a SingleFileZ page into a SingleFile page
import { extract } from "https://raw.githubusercontent.com/gildas-lormeau/single-filez-core/main/processors/compression/compression-extract.js";
import * as zip from "https://raw.githubusercontent.com/gildas-lormeau/zip.js/master/index.js";
globalThis.zip = zip;
const { docContent } = await extract(new Blob([await Deno.readFile(Deno.args[0])]), { noBlobURL: true });
if (Deno.args[1]) {
await Deno.writeTextFile(Deno.args[1], docContent);
} else {
console.log(docContent);
}
#!/bin/sh
if [ $# -eq 0 ]; then
echo
echo " Usage: $0 <INPUT FILE> [OUTPUT FILE]"
echo
echo " Transforms a page saved with SingleFileZ into a SingleFile page."
echo
echo " Arguments:"
echo
echo " INPUT FILE: path to a file containing a page saved with SingleFileZ"
echo " OUTPUT FILE: path of the output file"
echo
exit 1
else
deno run --allow-read --allow-write ./sfz2sf.js "$1" "$2"
fi
@gildas-lormeau
Copy link
Author

Thank you very much @nitincodery!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment