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

Feature request: check p5.js "version" from code. #2525

Closed
2 tasks done
grege2 opened this issue Jan 10, 2018 · 16 comments · Fixed by #5107 or #5165
Closed
2 tasks done

Feature request: check p5.js "version" from code. #2525

grege2 opened this issue Jan 10, 2018 · 16 comments · Fixed by #5107 or #5165
Assignees

Comments

@grege2
Copy link

grege2 commented Jan 10, 2018

Nature of issue?

  • New feature request

Most appropriate sub-area of p5.js?

  • Core

Details about the bug:

  • p5.js version: 0.5.16
  • Web browser and version: Chrome 63.0.3239.108
  • Operating System: Mac OS 10.12.6

New feature details:

It could be useful to have the p5.js version no. accessible from a properties query in code, ie. be able to read the "0.5.16" as above. In my case, this is just to ensure I'm running on a version no earlier than the one I developed on, a reasonable precaution. However, I'm aware that coding to explicit releases can lead to a minefield of special casing, which we already have mountains of in Web design, eg. the plethora of ugly hacks to deal with old Internet Explorers. Maybe p5.js designers are avoiding this.

(PS. Can I get it cleanly from project.version ? I'm not a JS expert.)

Thanks, GE.

@dhowe
Copy link
Contributor

dhowe commented Jan 10, 2018

+1 for this (or at least the version # at top of the p5.js file)

@lmccart
Copy link
Member

lmccart commented Jan 11, 2018

@dhowe the version number is currently at the top of the file: https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.16/p5.js
will see what we can do about including it in the code itself.

@grege2
Copy link
Author

grege2 commented Jan 11, 2018

Thanks Lauren.

@Jared-Sprague
Copy link
Contributor

@grege2 are you talking about a function you can call that will return the version number of the currently loaded p5 library? For example: p5.getVersion()

@grege2
Copy link
Author

grege2 commented Jan 11, 2018

Yes, that was the idea. Cheers, GE.

@limzykenneth
Copy link
Member

I think it can just be a constant attached to the p5 object, ie. p5.VERSION

@Spongman
Copy link
Contributor

Spongman commented Jan 11, 2018

ensure I'm running on a version no earlier than the one I developed on

i'm confused. isn't the version that's running just whatever you specify in the <script> tag in the .html file?

@meiamsome
Copy link
Member

@Spongman You don't necessarily have control if you're writing a library for p5 or similar

@grege2
Copy link
Author

grege2 commented Jan 12, 2018

@Spongman - Mmm, yes at present I specify the p5.js file in my <script> tag for my own development work. But I think I can foresee situations like @meiamsome mentioned, where I might not control the version.

@mikima
Copy link

mikima commented Nov 4, 2019

Yes that would be really useful, like having a VERSION constant or p5.getVersion() function

@dhowe
Copy link
Contributor

dhowe commented Jan 2, 2020

Reopening as it is important for a number of use-cases. For one, when you are using the editor and want to report a bug in p5.js, there is no easy way (correct me if I'm wrong here) to get the version from the bundled app

@micuat
Copy link
Member

micuat commented Mar 3, 2021

+1 as I also needed the constant from a bundled script.

I think adding this to the constants would make sense (e.g. THREE.js)

@rt1301
Copy link
Contributor

rt1301 commented Mar 16, 2021

@lmccart @limzykenneth I would like to work on this, if the issue is open.

@4molybdenum2
Copy link

@limzykenneth Can I submit a PR if this issue isn't already taken?

@micuat
Copy link
Member

micuat commented Apr 5, 2021

I just noticed that the const is only accessible when p5 is instantiated, which I totally didn't think about. This can be problematic in some (or most) use cases (when you need to check version after loading the module but before instantiation). Or am I missing something? if so please close the issue :)

@micuat micuat reopened this Apr 5, 2021
@limzykenneth
Copy link
Member

Maybe instead of defining the version number in constants.js it can be directly attached to p5 at the end of this file, ie p5.VERSION = "".

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