UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var helpers_1 = require("../util/helpers");
4function buildIonicGlobal(context) {
5 context.ionicGlobal = context.ionicGlobal || {};
6 // gather data to add to window.Ionic
7 var systemData = helpers_1.getSystemData(context.rootDir);
8 if (systemData.ionicFramework) {
9 context.ionicGlobal['version'] = "'" + systemData.ionicFramework + "'";
10 }
11 if (systemData.angularCore) {
12 context.ionicGlobal['angular'] = "'" + systemData.angularCore + "'";
13 }
14 if (systemData.ionicNative) {
15 context.ionicGlobal['ionicNative'] = "'" + systemData.ionicNative + "'";
16 }
17 var staticDir = helpers_1.toUnixPath(context.buildDir.replace(context.wwwDir, ''));
18 staticDir += '/';
19 if (staticDir.charAt(0) === '/') {
20 staticDir = staticDir.substring(1);
21 }
22 context.ionicGlobal['staticDir'] = "'" + staticDir + "'";
23 // output the JS
24 var o = [
25 '(function(w){',
26 'var i=w.Ionic=w.Ionic||{};'
27 ];
28 Object.keys(context.ionicGlobal).forEach(function (key) {
29 o.push("i." + key + "=" + context.ionicGlobal[key] + ";");
30 });
31 o.push('})(window);');
32 return o.join('');
33}
34exports.buildIonicGlobal = buildIonicGlobal;