Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

read from .env by default in inject() #70

Merged
merged 3 commits into from
Feb 28, 2018
Merged

read from .env by default in inject() #70

merged 3 commits into from
Feb 28, 2018

Conversation

xavdid
Copy link
Contributor

@xavdid xavdid commented Feb 28, 2018

Bumped the dotenv dependency, hence the path changes. Fixes PDE-76.

@xavdid xavdid requested a review from eliangcs February 28, 2018 00:23
tools.env.inject();
process.env.PIZZA.should.equal('Blackjack');
should.not.exist(process.env.CITY);
done();
Copy link
Member

@eliangcs eliangcs Feb 28, 2018

Choose a reason for hiding this comment

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

The tests are synchronous code, so I guess we don't need done() here. So are the other test cases in this file.


describe('read env', () => {
describe.only('read env', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove .only here? Seems mocha only runs the tests in test/tools/environment.js because of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh good catch. that was just for me, since I didn't want to run the whole suite every time. Will remove.

@@ -31,10 +31,29 @@ const cleanEnvironment = () => {
}
};

const localFilepath = filename => {
return path.join(process.cwd(), filename || '');
Copy link
Member

@eliangcs eliangcs Feb 28, 2018

Choose a reason for hiding this comment

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

Not sure if it's valid use case: Could a user inject an environment file using an absolute path? For example:

const zapier = require('zapier-platform-core');
zapier.tools.env.inject('/absolute/path/to/environment/file');

If so, we may want to adjust a bit here because path.join doesn't seem to handle absolute paths:

> process.cwd()
'/Users/eliang/Projects/zapier-platform/core'
> path.join(process.cwd(), '/root')
'/Users/eliang/Projects/zapier-platform/core/root'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they couldn't, but they also couldn't before. In master, we resolved their filename to the local directory anyway. We could expand that, but that seems like a more disruptive change (instead of renaming, they have to pass the whole path in).

'\nWARNING: `.environment` files will no longer be read by default in the next major version.',
'Either rename your file to `.env` or explicitly call this function with a filename:',
'\n zapier.tools.env.inject(".environment");\n\n'
].join('\n')
Copy link
Member

Choose a reason for hiding this comment

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

We may want to hide this when running tests.

@xavdid
Copy link
Contributor Author

xavdid commented Feb 28, 2018

Cleaned up in fd59bb7!

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.

None yet

2 participants