Check for base64 in CLI

This commit is contained in:
Brikaa 2021-10-15 16:51:11 +02:00
parent 64833a0408
commit 821d5496e4
1 changed files with 10 additions and 1 deletions

View File

@ -245,9 +245,18 @@ async function run_non_interactively(files, argv) {
exports.handler = async argv => { exports.handler = async argv => {
const files = [...(argv.files || []), argv.file].map(file_path => { const files = [...(argv.files || []), argv.file].map(file_path => {
const encoding =
(fs
.readFileSync(file_path)
.toString()
.split('')
.some(x => x.charCodeAt(0) >= 128) &&
'base64') ||
'utf8';
return { return {
name: path.basename(file_path), name: path.basename(file_path),
content: fs.readFileSync(file_path).toString(), content: fs.readFileSync(file_path).toString(encoding),
encoding,
}; };
}); });