Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Njb/use cross env #105

Merged
merged 6 commits into from
Dec 5, 2018
Merged

Conversation

NickBolles
Copy link
Contributor

Summary

  • Tell us about the problem your pull request is solving.
  • Are there any open issues that are related to this?
  • Is this PR dependent on PRs in other repos?

If so, please mention them to keep the conversations linked together.

Other Information

Use cross-env to set environment variables so that the scripts don't bomb out on windows

@eddyystop
Copy link
Member

eddyystop commented Nov 15, 2018

Feathers uses shx ( https://github.com/shelljs/shx ) and I don't want to introduce another player.

Would you mind converting to shx?

@NickBolles
Copy link
Contributor Author

@eddyystop sounds good. Looking into it briefly I'm not sure how I would do this with shx though.

I found this issue which references cross-env and it sounds like it's not really possible in shx.

Do you have any ideas?

@eddyystop
Copy link
Member

@daffl ^^^

@eddyystop
Copy link
Member

Is there any way at all to continue using shx?

Otherwise

  • Do we address this issue?
  • Do we introduce 2 overlapping utilities, shx and cross-env?
  • Do we replace shx with cross-env? Since package.json scripts are not regenerated, old apps would be using shx, while new ones cross-env.

@j2L4e
Copy link
Member

j2L4e commented Dec 3, 2018

I have little experience with shx, but from what's said in shelljs/shx#127 it seems like it can't replace cross-env functionality here

@eddyystop
Copy link
Member

@NickBolles Could you confirm that you can't do what you want to with shx. Shoujld that be the case, could you resolve the merge conflicts and I will merge.

@NickBolles
Copy link
Contributor Author

Yea, I couldn't get it to work. I'll resolve right now then it should be ready to merge.

generators/writing/templates/tsconfig.json Outdated Show resolved Hide resolved
let env = (config.tests || {}).environmentsAllowingSeedData || []<%- sc %>
let ifDbChangesAllowed = env.includes(process.env.NODE_ENV)<%- sc %>
let { tests: { environmentsAllowingSeedData = [] } = {}} = config<%- sc %>
let ifDbChangesAllowed = environmentsAllowingSeedData.includes(process.env.NODE_ENV)<%- sc %>
Copy link
Member

Choose a reason for hiding this comment

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

Could you revert these changes, too?

eddyystop [2:11 PM]
I've started using (config.tests || {}).environmentsAllowingSeedData because it can later be easily replaced by the optional chaining proposal config?.tests?.environmentsAllowingSeedData https://dev.to/sammyisa/optional-chaining-may-be-coming-to-javascript--4ff0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this to be a little utility function that takes the config. This way we can pass the config from the app instance

Copy link
Member

Choose a reason for hiding this comment

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

The thing I liked about ifDbChangesAllowed was that the dev can refer to it in the custom code. Its simpler than having to call the function with app.get('tests'). That var name can be a standard throughout DB mutating tests.

I don't want to cause a fuss but the generated code should always be as flexible as possible for customizations.

Copy link
Contributor Author

@NickBolles NickBolles Dec 4, 2018

Choose a reason for hiding this comment

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

I can undo this. But I don't really see how it makes things less flexible and it seems like importing the json directly will break config and introduce bugs.

I definitely get what you are getting at though, we want the code to be as flexible as possible, but this seems like a case where there's benefit to making this change, and that there's really one use to the variable, short circuit the seed data function

Copy link
Member

Choose a reason for hiding this comment

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

I agree the import should be replaced by app.get.

I was probably not clear enough. I like having ifDbChangesAllowed as an already set value for the user as it easier to find than the function.

It's possible the user remove the generated exit for something else and having a set value looks advantageous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eddyystop ahhh I see what you mean. Check my most recent commit for an update on this. Let me know if you were thinking anything different.

Copy link
Member

Choose a reason for hiding this comment

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

+1

@NickBolles
Copy link
Contributor Author

@j2L4e I updated those changes. Thanks for looking at them!

@eddyystop eddyystop merged commit 277589e into feathers-plus:master Dec 5, 2018
@eddyystop
Copy link
Member

Completed this PR with #137

@NickBolles
Copy link
Contributor Author

Thank for the help you guys!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants