Skip to content

Conversation

@casio
Copy link
Contributor

@casio casio commented Dec 1, 2016

currently this fixes #64

however, there's still ambiguity with the CLI flag importRoot and root coming from config files.
importRoot takes precedence now, but I guess both should just be named root.

also, we might consider output to be resolved around the same root. having thought about that a little more, I think we actually should not - most of the time the output will go into some arbitrarily located dist folder, I guess.

thoughts?

Copy link
Member

@simonsmith simonsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together @casio

I think having program.importRoot and config.root is okay. It allows us to release this change as a patch and seeing as you've set importRoot to take precedence over root that matches the expected behaviour.

I agree that output should be left alone.

bin/suitcss Outdated
if (input) {
var resolvedInput = importRoot ? resolve(importRoot, input) : resolve(input);
if (!exists(resolvedInput)) logger.fatal('not found', resolvedInput);
else input = resolvedInput;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use braces here for the if/else? Just matches it up with everything else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, done

@@ -59,15 +59,15 @@ describe('cli', function() {
});

it('should output stylelint warnings', function(done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are testing other feature, would you mind creating a suite only to test the importRoot thing instead of mixing tests up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, test/cli.js currently is really more of an integration test suite, no?
so imho its ok to test all i/o stuff there.
it would probably be cleaner to eg remove the -i options out of unrelated cases, though

Copy link
Member

@giuseppeg giuseppeg Dec 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean a nested describe in test/cli.js with the importRoot relevant tests.
The point is testing imports indirectly i.e. by tweaking other tests to cover some use cases it is not optimal.

@giuseppeg
Copy link
Member

should we also fix this part?

@simonsmith
Copy link
Member

@giuseppeg Do you mean normalising it so it always refers to root?

@giuseppeg
Copy link
Member

giuseppeg commented Dec 1, 2016

@simonsmith we said that CLI flags should always override config file options, in this case --importRoot won't because we check only for program['root'], we should add importRoot to the array.

Do you mean normalising it so it always refers to root?

Basically yes

@simonsmith
Copy link
Member

simonsmith commented Dec 4, 2016

Maybe get this merged and we can address the other issue separately. Do we just need to make those test case changes?

@giuseppeg
Copy link
Member

Do we just need to make those test case changes?

Yeah.
I can fix the other part in a follow-up branch if you prefer.

@simonsmith
Copy link
Member

Might be easier as it can be done in parallel. Then I think we're set to release a patch

@casio
Copy link
Contributor Author

casio commented Dec 6, 2016

hey guys! sorry, have been a bit busy & thus silent. please ping me if you'd like me to add more changes or squash the prev commits.

@simonsmith
Copy link
Member

@casio Not a problem, we're all busy at times :)

I think if you could address the feedback about grouping the tests in a single describe then we're good to go

simonsmith added a commit that referenced this pull request Dec 6, 2016
simonsmith added a commit that referenced this pull request Dec 6, 2016
@casio
Copy link
Contributor Author

casio commented Dec 7, 2016

so I just put the importRoot related test in its own nested describe block, as @giuseppeg suggested.
also I only checked for errors here(as @simonsmith did in his current pr).

it might be a good idea to, in one of the next steps, switch tests unrelated to importRoot to not make use if -i at all, but I thought that'd be better to do in another pr.

@simonsmith
Copy link
Member

@casio Yes, agreed. We can just give the full path to the fixtures which hilariously it seems like I had done even with -i which hid this bug in the first place :D

@casio
Copy link
Contributor Author

casio commented Dec 7, 2016

@simonsmith haha : )

fyi seeing appveyor bark, I just pushed an update. strangely the local lint task didnt catch that(done in describe call & a missing semicolon).

@simonsmith
Copy link
Member

I think this looks good to merge. @giuseppeg ?

@giuseppeg
Copy link
Member

giuseppeg commented Dec 7, 2016

@casio were the other tests failing after your changes? I think that importRoot shouldn't affect the input file path @simonsmith correct me if I am wrong.

@casio
Copy link
Contributor Author

casio commented Dec 7, 2016

@giuseppeg yes, they were. actually with how this is currently implemented, the name inputRoot would better mimic the behaviour.

and you're right, I guess: basically these are two different things - a root for the input(=entry) file and another one to resolve @import statements.

maybe it'd even be beneficial to revisit the concept/scope of how these things should work: ie. should it be rather import roots(plural), do we need a separate base path to resolve input and output, etc.
however I feel that'd go beyond the scope of this pr?

@simonsmith
Copy link
Member

I don't see any failing tests?

@casio
Copy link
Contributor Author

casio commented Dec 7, 2016

I think @giuseppeg meant tests that read like
... -i path/to/fixtures path/to/fixtures/input.css

Theses were failing with the new behavior since the cli tried to read
path/to/fixtures/path/to/fixtures/input.css then.

@giuseppeg
Copy link
Member

Yea imporRoot is about @imports not input files.
We should fix this, please also revert the changes to the old tests.

I can take a look at the issue again and the PR, I am just hopping on and off and I haven't been able to read it carefully because I am busy – sorry about that :)

@simonsmith
Copy link
Member

Interesting, I see what you guys mean.

Yeah it should relate directly to the postcss import root option.

@giuseppeg
Copy link
Member

Took a quick look, this is a non-issue because --import-root wasn't meant for this purpose i.e. pass input files without basepath. We should only fix #70 I suppose.

@simonsmith
Copy link
Member

simonsmith commented Dec 7, 2016

So are we saying the issue in #64 is expected?

Should the user be prepending the correct path to the input file?

@giuseppeg
Copy link
Member

giuseppeg commented Dec 7, 2016

It has always been like that. Ideally the root can be different than the input file's folder.

@simonsmith
Copy link
Member

I see. I guess that does correctly mimic how it would with postcss-import directly. You'd pass a full path to an input file and also be able to set a separate import root if needed. It is somewhat confusing but I think in most cases you rarely need to set -i.

@simonsmith
Copy link
Member

So it looks like this is PR is not worth merging then? I fear we may have led you down a wrong path @casio. My apologies if so D:

@casio
Copy link
Contributor Author

casio commented Dec 8, 2016

@simonsmith haha, no worries. was worth the ride : )

@casio casio closed this Dec 8, 2016
@giuseppeg
Copy link
Member

thank you for your time @casio! Sorry for the inconvenience.

simonsmith added a commit that referenced this pull request Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--import-root is being ignored

3 participants