diff --git a/src/index.ts b/src/index.ts index d2c8775..1fac964 100644 --- a/src/index.ts +++ b/src/index.ts @@ -53,6 +53,13 @@ async function run(inputFilePath: string | undefined) { false, toolDefaults ); + + // Make sure all the folders up to the output file exist, if not create them. + // This mirrors elm make behavior. + const outputDirectory = path.dirname(program.output); + if (!fs.existsSync(outputDirectory)) { + fs.mkdirSync(outputDirectory, { recursive: true }); + } fs.writeFileSync(program.output, transformed); const fileName = path.basename(inputFilePath); console.log('Success!');