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

Expose whether the command is running in dev or prod #28

Open
adam-lynch opened this issue Mar 2, 2020 · 2 comments
Open

Expose whether the command is running in dev or prod #28

adam-lynch opened this issue Mar 2, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@adam-lynch
Copy link

adam-lynch commented Mar 2, 2020

There's no easy way to tell whether the command is running in dev or not.

I could assume production production unless a certain environment variable exists, but that's not a great idea. It would require devs to set an environment variable (globally or when running the CLI on any machine) and if they forget, they might run something bad on a branch and it'll interact with production servers.

This is my current workaround; environment.js:

/*
	In production, commands are each bundled into a single file;
	e.g. /build/commands/index.js.
	That's why the following will be false in production
*/
const isDev = __filename.endsWith("environment.js");

export default Object.freeze({
	isDev
});

I use this in my commands/components to check if it's dev/prod
I suggest pastel sets process.env.NODE_ENV or something like that.

@adam-lynch
Copy link
Author

That doesn't work actually... I misunderstood. What we do now is store a file outside the build directory and check it at runtime

@vadimdemedes
Copy link
Owner

That's a good catch, will need to think how to approach this.

@vadimdemedes vadimdemedes changed the title Feature request: expose whether the command is running in dev or prod Expose whether the command is running in dev or prod May 24, 2023
@vadimdemedes vadimdemedes added the enhancement New feature or request label May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants