chore: testing #8637 (#8658)

Co-authored-by: Dimitris - Rafail Katsampas <katsampasdr@gmail.com>
This commit is contained in:
DimitrisRK
2020-06-20 01:36:13 +03:00
committed by GitHub
parent 41a21ea916
commit acddd1f34d
3 changed files with 10 additions and 7 deletions

View File

@ -4,7 +4,7 @@ import { path as fsPath, Folder, File } from "../file-system";
import * as trace from "../../trace"; import * as trace from "../../trace";
import * as appCommonModule from "../../application/application-common"; import * as appCommonModule from "../../application/application-common";
import { findMatch } from "../../module-name-resolver/qualifier-matcher/qualifier-matcher"; import { findMatch, stripQualifiers } from "../../module-name-resolver/qualifier-matcher/qualifier-matcher";
export class FileNameResolver implements FileNameResolverDefinition { export class FileNameResolver implements FileNameResolverDefinition {
private _context: PlatformContext; private _context: PlatformContext;
@ -36,6 +36,9 @@ export class FileNameResolver implements FileNameResolverDefinition {
path = fsPath.normalize(path); path = fsPath.normalize(path);
ext = "." + ext; ext = "." + ext;
// This call will return a clean path without qualifiers
path = stripQualifiers(path);
const candidates = this.getFileCandidatesFromFolder(path, ext); const candidates = this.getFileCandidatesFromFolder(path, ext);
result = findMatch(path, ext, candidates, this._context); result = findMatch(path, ext, candidates, this._context);

View File

@ -12,4 +12,4 @@ export interface PlatformContext {
export function findMatch(path: string, ext: string, candidates: Array<string>, context: PlatformContext): string; export function findMatch(path: string, ext: string, candidates: Array<string>, context: PlatformContext): string;
export function stripQualifiers(path: string): string export function stripQualifiers(path: string): string;

View File

@ -15,7 +15,7 @@ const minWidthHeightQualifier: QualifierSpec = {
return (new RegExp(`.${MIN_WH}\\d+`).test(path)); return (new RegExp(`.${MIN_WH}\\d+`).test(path));
}, },
getMatchOccurences: function (path: string): Array<string> { getMatchOccurences: function (path: string): Array<string> {
return path.match(new RegExp(`.${MIN_WH}\\d+`)); return path.match(new RegExp(`.${MIN_WH}\\d+`, "g"));
}, },
getMatchValue(value: string, context: PlatformContext): number { getMatchValue(value: string, context: PlatformContext): number {
const numVal = parseInt(value.substr(MIN_WH.length + 1)); const numVal = parseInt(value.substr(MIN_WH.length + 1));
@ -37,7 +37,7 @@ const minWidthQualifier: QualifierSpec = {
return (new RegExp(`.${MIN_W}\\d+`).test(path)) && !(new RegExp(`.${MIN_WH}\\d+`).test(path)); return (new RegExp(`.${MIN_W}\\d+`).test(path)) && !(new RegExp(`.${MIN_WH}\\d+`).test(path));
}, },
getMatchOccurences: function (path: string): Array<string> { getMatchOccurences: function (path: string): Array<string> {
return path.match(new RegExp(`.${MIN_W}\\d+`)); return path.match(new RegExp(`.${MIN_W}\\d+`, "g"));
}, },
getMatchValue(value: string, context: PlatformContext): number { getMatchValue(value: string, context: PlatformContext): number {
const numVal = parseInt(value.substr(MIN_W.length + 1)); const numVal = parseInt(value.substr(MIN_W.length + 1));
@ -59,7 +59,7 @@ const minHeightQualifier: QualifierSpec = {
return (new RegExp(`.${MIN_H}\\d+`).test(path)) && !(new RegExp(`.${MIN_WH}\\d+`).test(path)); return (new RegExp(`.${MIN_H}\\d+`).test(path)) && !(new RegExp(`.${MIN_WH}\\d+`).test(path));
}, },
getMatchOccurences: function (path: string): Array<string> { getMatchOccurences: function (path: string): Array<string> {
return path.match(new RegExp(`.${MIN_H}\\d+`)); return path.match(new RegExp(`.${MIN_H}\\d+`, "g"));
}, },
getMatchValue(value: string, context: PlatformContext): number { getMatchValue(value: string, context: PlatformContext): number {
const numVal = parseInt(value.substr(MIN_H.length + 1)); const numVal = parseInt(value.substr(MIN_H.length + 1));
@ -81,7 +81,7 @@ const platformQualifier: QualifierSpec = {
return path.includes(".android") || path.includes(".ios"); return path.includes(".android") || path.includes(".ios");
}, },
getMatchOccurences: function (path: string): Array<string> { getMatchOccurences: function (path: string): Array<string> {
return [".android", ".ios"]; return path.match(new RegExp("\\.android|\\.ios", "g"));
}, },
getMatchValue(value: string, context: PlatformContext): number { getMatchValue(value: string, context: PlatformContext): number {
const val = value.substr(1); const val = value.substr(1);
@ -95,7 +95,7 @@ const orientationQualifier: QualifierSpec = {
return path.includes(".land") || path.includes(".port"); return path.includes(".land") || path.includes(".port");
}, },
getMatchOccurences: function (path: string): Array<string> { getMatchOccurences: function (path: string): Array<string> {
return [".land", ".port"]; return path.match(new RegExp("\\.land|\\.port", "g"));
}, },
getMatchValue(value: string, context: PlatformContext): number { getMatchValue(value: string, context: PlatformContext): number {
const val = value.substr(1); const val = value.substr(1);