UNPKG

mobile-cli-lib

Version:
42 lines (41 loc) 2.01 kB
"use strict"; var path = require("path"); var util = require("util"); var constants_1 = require("../constants"); var ProjectFilesProviderBase = (function () { function ProjectFilesProviderBase($mobileHelper, $options) { this.$mobileHelper = $mobileHelper; this.$options = $options; } ProjectFilesProviderBase.prototype.getPreparedFilePath = function (filePath) { var projectFileInfo = this.getProjectFileInfo(filePath, ""); return path.join(path.dirname(filePath), projectFileInfo.onDeviceFileName); }; ProjectFilesProviderBase.prototype.getProjectFileInfo = function (filePath, platform, projectFilesConfig) { var parsed = this.parseFile(filePath, this.$mobileHelper.platformNames, platform || ""); var basicConfigurations = [constants_1.Configurations.Debug.toLowerCase(), constants_1.Configurations.Release.toLowerCase()]; if (!parsed) { var validValues = basicConfigurations.concat(projectFilesConfig && projectFilesConfig.additionalConfigurations || []), value = projectFilesConfig && projectFilesConfig.configuration || basicConfigurations[0]; parsed = this.parseFile(filePath, validValues, value); } return parsed || { filePath: filePath, onDeviceFileName: path.basename(filePath), shouldIncludeFile: true }; }; ProjectFilesProviderBase.prototype.parseFile = function (filePath, validValues, value) { var regex = util.format("^(.+?)[.](%s)([.].+?)$", validValues.join("|")); var parsed = filePath.match(new RegExp(regex, "i")); if (parsed) { return { filePath: filePath, onDeviceFileName: path.basename(parsed[1] + parsed[3]), shouldIncludeFile: parsed[2].toLowerCase() === value.toLowerCase() }; } return null; }; return ProjectFilesProviderBase; }()); exports.ProjectFilesProviderBase = ProjectFilesProviderBase;