Skip to content

Commit b3a6fce

Browse files
committed
fix: respect nsconfig options when updating tsconfig on postinstall
fixes #60
1 parent 36a2bf7 commit b3a6fce

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Diff for: tsconfig-upgrader.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,29 @@ function addTnsCoreModulesPathMappings(existingConfig, displayableTsconfigPath,
118118
var compilerOptions = existingConfig["compilerOptions"];
119119
compilerOptions["baseUrl"] = ".";
120120
compilerOptions["paths"] = compilerOptions["paths"] || {};
121+
122+
const appPath = getAppPath(projectDir);
123+
console.log(appPath);
121124
compilerOptions["paths"]["~/*"] = compilerOptions["paths"]["~/*"] || [
122-
"app/*"
125+
`${appPath}/*`
123126
];
124127
compilerOptions["paths"]["*"] = compilerOptions["paths"]["*"] || [
125128
"./node_modules/tns-core-modules/*",
126129
"./node_modules/*"
127130
];
128131
}
129132
}
133+
134+
function getAppPath(projectDir) {
135+
const DEFAULT_PATH = "app";
136+
const nsConfigPath = path.join(projectDir, "nsconfig.json");
137+
138+
let nsConfig;
139+
try {
140+
nsConfig = JSON.parse(fs.readFileSync(nsConfigPath));
141+
const appPath = nsConfig && nsConfig.appPath;
142+
return appPath || DEFAULT_PATH;
143+
} catch(_) {
144+
return DEFAULT_PATH;
145+
}
146+
}

0 commit comments

Comments
 (0)