There is not an actual way to get the current OS. The only thing I can suggest is hacky, but should work in most cases. The idea is to get the User-Agent
of the last request you have sent and extract the OS X version from it:
// last HTTP exchange of the current request
var exchange = context.getCurrentRequest().getLastExchange();
// user agent
var ua = exchange.getRequestHeaderByName("User-Agent");
// parse user agent
var matches = ua.match(/OS X\/(\d+(?:\.\d+)*)/);
// full OS name
// OS X/10.10.4
var os = matches[0];
// version string
// 10.10.4
var version = matches[1];
Or as a one-liner:
// 10.10.4
return context.getCurrentRequest().getLastExchange().getRequestHeaderByName("User-Agent").match(/OS X\/(\d+(?:\.\d+)*)/)[1];