Skip to content

Commit

Permalink
issue #3 : make output able to recreate recursive directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Acuao committed Oct 31, 2023
1 parent 2dcf247 commit 4f72943
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ if(options.decode){
// handle output
const outputBuffer = Buffer.from(inputAsB64string, inputEncoding);
if(options.outputFile){

// create recursive directories for output
fs.mkdirSync(path.dirname(options.outputFile), {recursive:true});

if(options.decode){
fs.writeFileSync(options.outputFile, Buffer.from(inputAsB64string,'base64' ));
} else {
Expand Down
16 changes: 16 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ fs.rmSync('test/encoded.tmp.gif');



console.log(chalk.blue('output into non-existent recursive folders', ':'));
execSync('node dist/src/index.js -e -i test/bus.gif -o test/out1/out2/encoded.tmp.gif');

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









Expand Down

0 comments on commit 4f72943

Please sign in to comment.