From 0d97e00d33a8f9f63018941f88c93af6f78bd289 Mon Sep 17 00:00:00 2001 From: Brenton House Date: Tue, 6 Aug 2019 13:42:57 -0500 Subject: [PATCH 1/3] added support for code xml element --- Alloy/commands/compile/parsers/Ti.UI.Code.js | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 Alloy/commands/compile/parsers/Ti.UI.Code.js diff --git a/Alloy/commands/compile/parsers/Ti.UI.Code.js b/Alloy/commands/compile/parsers/Ti.UI.Code.js new file mode 100755 index 000000000..794626692 --- /dev/null +++ b/Alloy/commands/compile/parsers/Ti.UI.Code.js @@ -0,0 +1,31 @@ +var _ = require('lodash'); +var CONST = require('../../../common/constants'); +var CU = require('../compilerUtils'); +var U = require('../../../utils'); +var fs = require('fs-extra'); +var path = require('path'); + +exports.parse = function(node, state) { + var args = CU.getParserArgs(node, state); + var compilerConfig = CU.getCompilerConfig(); + var code = ''; + + function getSourceCode(src) { + if ( src) { + const sourcePath = path.join(compilerConfig.dir.resourcesPlatform, src); + if (fs.existsSync(sourcePath)) { + return fs.readFileSync(sourcePath, 'utf8'); + } + } + } + + // get code from any external source + code += getSourceCode(args.createArgs.src) || ''; + + // get code from text node + code += U.XML.getNodeText(node) || ''; + + return { + code: code.trim() + '\n', + }; +}; From c7c85fe74bbf4772f3f8b13af9b2f7afe5efcf46 Mon Sep 17 00:00:00 2001 From: Brenton House Date: Tue, 6 Aug 2019 13:47:33 -0500 Subject: [PATCH 2/3] removed unused variables --- Alloy/commands/compile/parsers/Ti.UI.Code.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Alloy/commands/compile/parsers/Ti.UI.Code.js b/Alloy/commands/compile/parsers/Ti.UI.Code.js index 794626692..76e455495 100755 --- a/Alloy/commands/compile/parsers/Ti.UI.Code.js +++ b/Alloy/commands/compile/parsers/Ti.UI.Code.js @@ -1,5 +1,3 @@ -var _ = require('lodash'); -var CONST = require('../../../common/constants'); var CU = require('../compilerUtils'); var U = require('../../../utils'); var fs = require('fs-extra'); @@ -26,6 +24,6 @@ exports.parse = function(node, state) { code += U.XML.getNodeText(node) || ''; return { - code: code.trim() + '\n', + code: code.trim() + '\n\n', }; }; From 4222349d4ea1cebc252c55adf2e5d3bc6b5529d9 Mon Sep 17 00:00:00 2001 From: Brenton House Date: Thu, 3 Oct 2019 14:30:25 -0500 Subject: [PATCH 3/3] renamed from code to script --- Alloy/commands/compile/parsers/{Ti.UI.Code.js => Ti.UI.Script.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Alloy/commands/compile/parsers/{Ti.UI.Code.js => Ti.UI.Script.js} (100%) diff --git a/Alloy/commands/compile/parsers/Ti.UI.Code.js b/Alloy/commands/compile/parsers/Ti.UI.Script.js similarity index 100% rename from Alloy/commands/compile/parsers/Ti.UI.Code.js rename to Alloy/commands/compile/parsers/Ti.UI.Script.js