mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Merge pull request #1684 from NativeScript/codefile
Loading of codeFile should not mask exceptions
This commit is contained in:
@ -79,11 +79,13 @@ export function getComponentModule(elementName: string, namespace: string, attri
|
||||
if (codeFilePath.indexOf("~/") === 0) {
|
||||
codeFilePath = path.join(knownFolders.currentApp().path, codeFilePath.replace("~/", ""));
|
||||
}
|
||||
try {
|
||||
|
||||
let codeFilePathWithExt = codeFilePath.indexOf(".js") !== -1 ? codeFilePath : `${codeFilePath}.js`;
|
||||
if (File.exists(codeFilePathWithExt)) {
|
||||
exports = global.loadModule(codeFilePath);
|
||||
(<any>instance).exports = exports;
|
||||
} catch (ex) {
|
||||
throw new Error(`Code file with path "${codeFilePath}" cannot be found!`);
|
||||
} else {
|
||||
throw new Error(`Code file with path "${codeFilePathWithExt}" cannot be found!`);
|
||||
}
|
||||
} else {
|
||||
throw new Error("Code file atribute is valid only for pages!");
|
||||
|
Reference in New Issue
Block a user