Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shouldn't be able to use --dir and -o together #166

Closed
zachary95 opened this issue Oct 23, 2017 · 5 comments
Closed

Shouldn't be able to use --dir and -o together #166

zachary95 opened this issue Oct 23, 2017 · 5 comments
Assignees
Labels
Milestone

Comments

@zachary95
Copy link

Hello,

I'm experiencing some issues by executing this command:

postcss components/**/*.css --dir 'wouldBeIgnoredAnyway' -o 'styles/app.css'

It compiles every source files well but output only contains the last compiled file.

I've checked the source code, that's because css() does fs.outputFile() which overwrite content every time one input get proceed.

Yet, I did a little fix on a fork available here : https://github.com/TheSuperFly/postcss-cli/tree/fix/overwritting. I'll create a pull request when a maintainer confirms that's a real issue and not a bad usage.

@michael-ciniawsky
Copy link
Contributor

michael-ciniawsky commented Oct 23, 2017

This is bad usage as implicit concatenation should be avoided, please use postcss-import instead with the --dir dest/ flag in case you have multiple dest CSS files (complete1.css, complete2.css, ... etc (src/*.css)).

@RyanZim
Copy link
Collaborator

RyanZim commented Oct 23, 2017

That's poor usage; --dir and -o are supposed to be mutually exclusive. It is a bug that postcss-cli doesn't throw an error when you use them together.

@RyanZim RyanZim self-assigned this Oct 23, 2017
@RyanZim RyanZim changed the title Multiple inputs with one output file create an incomplete output Shouldn't be able to use --dir and -o together Oct 23, 2017
@zachary95
Copy link
Author

zachary95 commented Oct 23, 2017

Ok, I see. So if you don't want this issue to be filled again, either we should trigger an error to avoid this behavior of overwritting or handle it nicely by handling multiple inputs when one output is expected, like sass's cli does transparently.

AHMA, option two is the way to go since I've been using postcss in a react (next.js) context where stylesheet belongs to components and should not require to edit global reference for being used, added or removed.

In my fork, I did a fs.append() on each compilation which could make a live reload system go crazy. But as an improvement, I can hold an certain amount of compiled sources in memory then commit at a certain moment to avoid memory leak.

Now you choose! 😄

@RyanZim
Copy link
Collaborator

RyanZim commented Oct 23, 2017

Yeah, going to trigger an error here. Implicit concatenation isn't something I want, since I can't guarantee the order the files are appended to the output will always be consistent.

@michael-ciniawsky
Copy link
Contributor

Yep, should throw. next.js (webpack) file structure is out-of-scope

@RyanZim RyanZim added the bug label Dec 5, 2017
RyanZim added a commit that referenced this issue Dec 6, 2017
- Remove extra aliases -x, -p, -s, -t, -e, -b, & -c
- Better usage text
- Split opts into groups in the --help message
- Way stricter opts parsing to prevent stupid combinations of options

Fixes #166; Fixes #126
@RyanZim RyanZim added this to the 5.0.0 milestone Dec 6, 2017
@RyanZim RyanZim closed this as completed in cc3f696 Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants