The upcoming 1.2 version of Alloy uses a new utility module named BuildLog which reads and writes a JSON file at build/alloy/build.json. For now it’s used only to log the selected theme. This way the compiler can tell if the theme has changed since the previous compile and optimize the current one.
You can use this module in your alloy.jmk
file to log other stuff you need to persist between builds. As an example, the following would use BuildLog to store and retrieve the timestamp of the last compile. You could use this then to search for specific changes since that time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
task("pre:compile", function(event, logger) { // Require the module var BuildLog = require('./BuildLog'); // Create an instance, which will read the JSON file var buildLog = new BuildLog(event.dir.project); // Get the timestamp of the previous compile var previous = buildLog.data.timestamp; // Do some stuff you need the timestamp for ;) // Store the current timestamp for the next one buildLog.data.unRetina = parseInt(Date.now()); // Write to the JSON file buildLog.write(); }); |
Just be aware Tony told me the module might not be around for long ;)