0

I am working on a project for which the end client gets a lot of build.

Sometimes a fix is reported not repaired when it has been and it turns out the latest build has not been uploaded by they tech team. Our solution to this has been to comment by hand a date of release as we send it out, then we can check they upload and compare to our build.

We want to remove the risk of one of the team forgetting to version number a build, is it possible using a pre-processor to add one as a comment or even a JS var.

I know uglify.js has a 'define' parameter function, would this work, no one in the team has experience in this? We are also using compass to combine scss files.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Kevin Mann
  • 721
  • 1
  • 7
  • 14
  • 1
    You could use the `banner` option if you're using Grunt - https://github.com/gruntjs/grunt-contrib-uglify#banner – Nick R Jun 10 '14 at 15:36
  • I am not currently using Grunt but it seems very interesting, the banner and footer options would be useful. – Kevin Mann Jun 11 '14 at 09:06
  • Perhaps useful if you go down the grunt preprocessing path: https://github.com/steveax/grunt-revgithash – steveax Jun 16 '14 at 07:13

1 Answers1

1

Without knowing more about your build process it's difficult to give the best answer. (How are uglify and compass invoked?)

Here is one method:

(echo -n '// '; date; uglify input) > output

This is a Linux command that prepends the output of the date command to the output of uglify (source). A similar batch file could be written for Windows environments. Or Grunt could be used for a cross-platform solution...


Myself, I developed a system that automatically incorporates the Git version when building my project.

  • The build output contains a version like this: v0.2.9.9 6gec43+ It's a combination of tags and fragment of the Git commit SHA. The SHA fragment usually pinpoints the exact version of the project source files.
  • The process is automated via git post-commit hooks. After each commit, a shell script is run. This script writes version.js, a tiny JavaScript module that simply stores the current project version (or 'UNKNOWN' if not available for some reason. Could fall back to the date, too.)
  • View my script, based on this script.
Leftium
  • 16,497
  • 6
  • 64
  • 99
  • I am using codekit, to manage the preprocessing. I do have git and your approach makes a lot of sense. I will look at that more, thank you. I have been looking at add code to the compass config ruby file which will use the on stylesheet save callback to add a comment to the css files with a date, but running into write permission error. – Kevin Mann Jun 11 '14 at 09:01