Skip to content

Commit

Permalink
add the same improvements mades for the issue #3 for --html
Browse files Browse the repository at this point in the history
  • Loading branch information
Acuao committed Nov 1, 2023
1 parent 23bc0e1 commit d32a098
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "base64-advanced-cli",
"version": "1.3.0",
"version": "1.3.1",
"description": "Command line interface for advanced base 64 encoding/decoding",
"scripts": {
"dev": "tsc -w",
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ if(options.html) {
const mimeType = base64ImageMime.getImageMime(imageContentB64);
const imageHtml= `<img src="data:${mimeType};base64,${imageContentB64}" />`;
if(options.outputFile){
// create recursive directories for output
fs.mkdirSync(path.dirname(options.outputFile), {recursive:true});

fs.writeFileSync(options.outputFile, imageHtml);
} else {
console.log(chalk.yellow(imageHtml));
Expand Down
14 changes: 14 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ fs.rmSync('test/image.tmp.html');



console.log(chalk.blue('html image encoding to file with recursive', ':'));
execSync('node dist/src/index.js -e --html -i test/in-love-small.png -o test/out1/out2/image.tmp.html');

if(getFileSha256('./test/out1/out2/image.tmp.html') === getFileSha256('./test/html-image-output.html')){
console.log(chalk.green('TEST Success !'));
} else {
console.log(chalk.red('TEST Failed !'));
errorCount ++;
}
fs.rmSync('test/out1', {recursive:true});





console.log(chalk.blue('decode from file to file', ':'));
execSync('node dist/src/index.js -d -i test/bus.gif.b64 -o test/decoded.tmp.gif');
Expand Down

0 comments on commit d32a098

Please sign in to comment.