diff --git a/cli/commands/execute.js b/cli/commands/execute.js index c69d3a0..4929ccc 100644 --- a/cli/commands/execute.js +++ b/cli/commands/execute.js @@ -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, }; });