diff --git a/src/index.ts b/src/index.ts index 1a6e1d2..dc04e59 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { diff --git a/test/test.ts b/test/test.ts index ea9ccb7..0832ab2 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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}); + + + + + +