Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
Remove a try/catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
bundyo committed Jan 28, 2020
1 parent 7734f5c commit 58da6e5
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions plugins/PlatformFSPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,21 @@ export function mapFileSystem(args: MapFileSystemArgs): any {
const {dir, name, ext} = parseFile(file);
let platformFilePath = join(dir, `${name}.${platform}${ext}`);

try {
require.resolve(platformFilePath);
} catch (e) {
if (isExternal && dir.indexOf("/@nativescript/core/") !== -1) {
let replacedPath;
try {
replacedPath = dir.replace(
/node_modules(\/[^/]+)?\/@nativescript\/core/,
`node_modules/nativescript-platform-${platform}`
);

platformFilePath = require.resolve(join(replacedPath, `${name}.${platform}${ext}`));
} catch (e) {
if (replacedPath) {
if (ext === ".d") {
platformFilePath = undefined;
} else {
platformFilePath = join(replacedPath, `${name}${ext}`);
}
if (isExternal && dir.indexOf("/@nativescript/core/") !== -1) {
let replacedPath;
try {
replacedPath = dir.replace(
/node_modules(\/[^/]+)?\/@nativescript\/core/,
`node_modules/nativescript-platform-${platform}`
);

platformFilePath = require.resolve(join(replacedPath, `${name}.${platform}${ext}`));
} catch (e) {
if (replacedPath) {
if (ext === ".d") {
platformFilePath = undefined;
} else {
platformFilePath = join(replacedPath, `${name}${ext}`);
}
}
}
Expand Down

0 comments on commit 58da6e5

Please sign in to comment.