mjml-cli doesn't create the target directory when parsing multiple files

Created on 1 Jul 2018  Â·  4Comments  Â·  Source: mjmlio/mjml

When running mjml-cli on multiple files using a glob pattern and the target directory doesn't exist, then the output is a single file without file extension, in the root directory.

If I create the dist directory before running the mjml command, then the output is generated as expected, with one HTML file for each corresponding MJML file.

Since I want to ignore my dist directory from source control, having to create the dist directory manually before building the project is inconvenient.

Reproduction Steps:

  1. Create a src directory, with at east one mjml file in it.
  2. Make sure the dist directory does NOT exist
  3. Run mjml ./src/*.mjml -o ./dist/

Expected behavior:

A directory dist is created, and a HTML file is created within the dist directory for each corresponding MJML file in the src directory.

Observed behavior:

A single file with filename dist and without a file extension is created in the root directory, containing transpiled HTML.

MJML version:

mjml-core: 4.0.5
mjml-cli: 4.0.5

Node: 8.9.3

Most helpful comment

@iRyusa Bumped to 4.1, but still having the same problem unfortunately.

To anyone having the same issue, my current workaround, to be sure the target is clean and always exist is: rimraf ./dist && mkdirp ./dist && mjml ./src/*.mjml -o ./dist/

All 4 comments

Hi can you try to update with 4.1 please ?

On Sun, Jul 1, 2018 at 12:03 AM Christofer Eliasson <
[email protected]> wrote:

When running mjml-cli on multiple files using a glob pattern and the
target directory doesn't exist, then the output is a single file without
file extension, in the root directory.

If I create the dist directory before running the mjml command, then the
output is generated as expected, with one HTML file for each corresponding
MJML file.

Since I want to ignore my dist directory from source control, having to
create the dist directory manually before building the project is
inconvenient.

Reproduction Steps:

  1. Create a src directory, with at east one mjml file in it.
  2. Make sure the dist directory does NOT exist
  3. Run mjml ./src/*.mjml -o ./dist/

Expected behavior:

A directory dist is created, and a HTML file is created within the dist
directory for each corresponding MJML file in the src directory.

Observed behavior:

A single file with filename dist and without a file extension is created
in the root directory, containing transpiled HTML.

MJML version:

mjml-core: 4.0.5
mjml-cli: 4.0.5

Node: 8.9.3

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mjmlio/mjml/issues/1262, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAizzdxwSrmcZbbFD7jASUS_9-qcFYgLks5uB_WUgaJpZM4U-Hfl
.

--
Cordialement,
Maxime BRAZEILLES

@iRyusa Bumped to 4.1, but still having the same problem unfortunately.

To anyone having the same issue, my current workaround, to be sure the target is clean and always exist is: rimraf ./dist && mkdirp ./dist && mjml ./src/*.mjml -o ./dist/

I think we added a check at somepoint to ensure that output directory
should exist, we'll check what happens then thanks for reporting it.

On Sun, Jul 1, 2018 at 12:25 AM Christofer Eliasson <
[email protected]> wrote:

@iRyusa https://github.com/iRyusa Bumped to 4.1, but still having the
same problem unfortunately.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mjmlio/mjml/issues/1262#issuecomment-401569988, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAizzfDhlnPUGnNj9EiagIMYNGQwmUaGks5uB_rigaJpZM4U-Hfl
.

--
Cordialement,
Maxime BRAZEILLES

Hi @c-eliasson We should indeed specify in the doc that the output directory must already exists, but this is the normal behavior. There are already multiple cases to handle depending on input/ouput being files or directories, so we think it's safer not to create directories.

We added more logging about this :
If i run mjml test/*.mjml -o ./dist/ with multiple mjml files in the test dir, it outputs Multiple input files, but output option should be either an existing directory or an empty string: ./dist given
If i run the same command with only one file, it outputs Error writing file - ./dist/ : Error: ENOENT: no such file or directory, open './dist/'
Finally if i run mjml test/*.mjml -o ./dist with only one input file, it assumes ./dist is the output file and create it.

Was this page helpful?
0 / 5 - 0 ratings