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

get version constant from package.json #5107

Merged
merged 4 commits into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

const _PI = Math.PI;

/**
* Version of this p5.js.
* @property {String} VERSION
* @final
*/
export const VERSION =
'VERSION_CONST_WILL_BE_REPLACED_BY_BROWSERIFY_BUILD_PROCESS';

// GRAPHICS RENDERER
/**
* The default, two-dimensional renderer.
Expand Down
5 changes: 5 additions & 0 deletions tasks/build/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ module.exports = function(grunt) {
code += data;
})
.on('end', function() {
code = code.replace(
`'VERSION_CONST_WILL_BE_REPLACED_BY_BROWSERIFY_BUILD_PROCESS'`,
grunt.template.process(`'<%= pkg.version %>'`)
);

// "code" is complete: create the distributable UMD build by running
// the bundle through derequire
// (Derequire changes the bundle's internal "require" function to
Expand Down