mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Co-authored-by: Dimitris - Rafail Katsampas <katsampasdr@gmail.com>
This commit is contained in:
@ -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);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
Reference in New Issue
Block a user