Skip to content

Commit 5a2202c

Browse files
committed
Remove special tns_core_modules path handling
1 parent d28a406 commit 5a2202c

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

src/common/utilities.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,30 @@ export function retryAsync(fn: () => Promise<any>, timeoutMs: number): Promise<a
8383
}
8484

8585
function tryFindSourcePathInNSProject(nsProjectPath: string, additionalFileExtension: string, resorcePath: string) : string {
86-
let guesses = [];
86+
let guess: string = "";
8787
const pathParts = resorcePath.split(path.sep);
8888
let appIndex = pathParts.indexOf("app");
8989
let isTnsModule = appIndex >= 0 && pathParts.length > appIndex + 1 && pathParts[appIndex + 1] === "tns_modules";
9090
//let isTnsModule: boolean = (pathParts.length >= 3 && pathParts[0] == '' && pathParts[1] == 'app' && pathParts[2] == 'tns_modules');
9191
if (isTnsModule) {
92-
// the file is part of a module, so we search it in '{ns-app}/node_modules/tns-core-modules/' and '{ns-app}/node_modules/'
92+
// the file is part of a module, so we search it in '{ns-app}/node_modules/'
9393
let nsNodeModulesPath: string = path.join(nsProjectPath, 'node_modules');
94-
let tnsCoreNodeModulesPath: string = path.join(nsNodeModulesPath, 'tns-core-modules');
9594

9695
let modulePath: string = path.join.apply(path, pathParts.slice(appIndex + 2));
97-
guesses.push(path.join(tnsCoreNodeModulesPath, modulePath));
98-
guesses.push(path.join(nsNodeModulesPath, modulePath));
96+
guess = path.join(nsNodeModulesPath, modulePath);
9997
}
10098
else {
101-
guesses.push(path.join(nsProjectPath, resorcePath));
99+
guess = path.join(nsProjectPath, resorcePath);
102100
}
103101

104-
for (var guessPath of guesses) {
105-
if (existsSync(guessPath)) {
106-
return canonicalizeUrl(guessPath);
107-
}
102+
if (existsSync(guess)) {
103+
return canonicalizeUrl(guess);
104+
}
108105

109-
let extension: string = path.extname(guessPath);
110-
let platformSpecificPath: string = guessPath.substr(0, guessPath.length - extension.length) + '.' + additionalFileExtension + extension;
111-
if (existsSync(platformSpecificPath)) {
112-
return canonicalizeUrl(platformSpecificPath);
113-
}
106+
let extension: string = path.extname(guess);
107+
let platformSpecificPath: string = guess.substr(0, guess.length - extension.length) + '.' + additionalFileExtension + extension;
108+
if (existsSync(platformSpecificPath)) {
109+
return canonicalizeUrl(platformSpecificPath);
114110
}
115111

116112
return null;

src/debug-adapter/adapter/pathTransformer.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,7 @@ export class PathTransformer implements DebugProtocol.IDebugTransformer {
5656
}
5757
else if (this.inferedDeviceRoot) {
5858
let inferedUrl = url.replace(this._appRoot, this.inferedDeviceRoot).replace(/\\/g, "/");
59-
60-
//change device path if {N} core module or {N} module
61-
if (inferedUrl.indexOf("/node_modules/tns-core-modules/") != -1)
62-
{
63-
inferedUrl = inferedUrl.replace("/node_modules/tns-core-modules/", "/app/tns_modules/");
64-
}
65-
else if (inferedUrl.indexOf("/node_modules/") != -1)
66-
{
67-
inferedUrl = inferedUrl.replace("/node_modules/", "/app/tns_modules/");
68-
}
59+
inferedUrl = inferedUrl.replace("/node_modules/", "/app/tns_modules/");
6960

7061
//change platform specific paths
7162
inferedUrl = inferedUrl.replace(`.${this._platform}.`, '.');

0 commit comments

Comments
 (0)