Merge pull request #2085 from keymanapp/developer-package-compiler-spurious-error-model-and-keyboard-fixes-2081

[Developer] Prevent package metadata preprocessor from treating .model.js files as keyboard files when they don't exist.
This commit is contained in:
Marc Durdin 2019-09-19 07:55:23 +10:00 committed by GitHub
commit d2de4f46ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@ type
function IsKeyboardFileByContent(f: TPackageContentFile): Boolean;
function CheckKeyboardLanguages: Boolean;
function CheckKeyboardTargetVersions: Boolean;
function IsModelFileByName(f: TPackageContentFile): Boolean;
public
type TPackageKeyboardInfo = record
Name, ID, Version: string;
@ -222,6 +223,11 @@ begin
end;
end;
function TPackageInfoRefreshKeyboards.IsModelFileByName(f: TPackageContentFile): Boolean;
begin
Result := TRegEx.IsMatch(f.FileName, '\.model\.js$', [roIgnoreCase]);
end;
function TPackageInfoRefreshKeyboards.IsKeyboardFileByName(f: TPackageContentFile): TKMFileType;
begin
if f.FileType = ftKeymanFile then
@ -232,6 +238,12 @@ begin
if f.FileType <> ftJavascript then
Exit(ftOther);
// A lexical model file will typicaly have the extension .model.js. This prevents the
// package editor from treating a lexical model as a keyboard when refreshing the list
// of included keyboards
if IsModelFileByName(f) then
Exit(ftOther);
// Need to test if the JS is a valid keyboard file.
// This is a bit of a pain... but we have to stick with .js for compat
if not FileExists(f.FileName) or IsKeyboardFileByContent(f) then