From 5bc0764161a1ca9f2131f01b7b8887eb26b2c1a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20von=20der=20Gr=C3=BCn?= Date: Fri, 4 May 2018 23:11:40 -0700 Subject: [PATCH] CB-13471: Fix tests and path issues for Windows --- spec/ConfigChanges/ConfigFile.spec.js | 6 ++++++ src/ConfigChanges/ConfigFile.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/ConfigChanges/ConfigFile.spec.js b/spec/ConfigChanges/ConfigFile.spec.js index 3d3f64ee..2da5ee89 100644 --- a/spec/ConfigChanges/ConfigFile.spec.js +++ b/spec/ConfigChanges/ConfigFile.spec.js @@ -82,4 +82,10 @@ describe('ConfigFile tests', function () { var configPath = path.join('project_dir', 'app', 'src', 'main', file, 'xml'); expect(configFile.resolveConfigFilePath('project_dir', 'android', file)).toBe(configPath); }); + + it('resolveConfigFilePath should return file path', function () { + var file = 'res/xml'; + var configPath = path.join('project_dir', 'app', 'src', 'main', file, 'xml'); + expect(configFile.resolveConfigFilePath('project_dir', 'android', file)).toBe(configPath); + }); }); diff --git a/src/ConfigChanges/ConfigFile.js b/src/ConfigChanges/ConfigFile.js index 6f4f4c98..eb6df45e 100644 --- a/src/ConfigChanges/ConfigFile.js +++ b/src/ConfigChanges/ConfigFile.js @@ -166,6 +166,8 @@ function resolveConfigFilePath (project_dir, platform, file) { var filepath = path.join(project_dir, file); var matches; + file = path.normalize(file); + if (file.indexOf('*') > -1) { // handle wildcards in targets using glob. matches = modules.glob.sync(path.join(project_dir, '**', file)); @@ -195,7 +197,7 @@ function resolveConfigFilePath (project_dir, platform, file) { } else if (file.endsWith('strings.xml')) { // Plugins really shouldn't mess with strings.xml, since it's able to be localized filepath = path.join(project_dir, 'app', 'src', 'main', 'res', 'values', 'strings.xml'); - } else if (file.match(/res\/xml/)) { + } else if (file.includes(path.join('res', 'xml'))) { // Catch-all for all other stored XML configuration in legacy plugins var config_file = path.basename(file); filepath = path.join(project_dir, 'app', 'src', 'main', 'res', 'xml', config_file);