Titanium JIRA Archive
Alloy (ALOY)

[ALOY-999] Alloy: Add Compile time defines functionality

GitHub Issuen/a
TypeImprovement
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sAlloy 1.3.1
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterNeville Dastur
AssigneeUnknown
Created2014-04-20T17:07:48.000+0000
Updated2018-03-07T22:25:52.000+0000

Description

In most build environments constants can be defined at build time. E.g. -D for make. This allows us to define a string such as the Git revision of the build or the build time. It would be great if alloy had this ability. I tried doing it via manipulation of config.json in alloy.jmk, but pre-compile is invoked further into the compile process. A hook where I could do this would be great:
task("pre:true-precompile",function(event,logger){
   var now = new Date();

    // Either this ....
    event.alloyConfig.buildDate = now.toUTCString();

    // ... or this
    var fs = require('fs');
    fs.readFile(event.dir.project + '/app/config.json', function(err, data) {
    	var config = JSON.parse( data );

    	config.global.buildDate = now.toUTCString();

    	var newConfig = JSON.stringify( config, null, 4);

    	fs.writeFile(event.dir.project + '/app/config.json', newConfig, function (err) {
		  if (err) throw err;
		  logger.info('New config.json saved.');
		}); 
	});

});

Comments

  1. Ritu Agrawal 2014-04-30

    Moving this improvement request to engineering for further evaluation and prioritization.
  2. Neville Dastur 2015-06-02

    Having passed 1st year anniversary I thought I would ask if it was for consideration? Thanks ;)

JSON Source