Check for base64 in CLI
This commit is contained in:
parent
64833a0408
commit
821d5496e4
|
@ -245,9 +245,18 @@ async function run_non_interactively(files, argv) {
|
|||
|
||||
exports.handler = async argv => {
|
||||
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 {
|
||||
name: path.basename(file_path),
|
||||
content: fs.readFileSync(file_path).toString(),
|
||||
content: fs.readFileSync(file_path).toString(encoding),
|
||||
encoding,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue