Skip to content

Commit 9dc06b8

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

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Diff for: tsconfig-upgrader.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,28 @@ function addTnsCoreModulesPathMappings(existingConfig, displayableTsconfigPath,
118118
var compilerOptions = existingConfig["compilerOptions"];
119119
compilerOptions["baseUrl"] = ".";
120120
compilerOptions["paths"] = compilerOptions["paths"] || {};
121+
122+
const appPath = getAppPath(projectDir);
121123
compilerOptions["paths"]["~/*"] = compilerOptions["paths"]["~/*"] || [
122-
"app/*"
124+
`${appPath}/*`
123125
];
124126
compilerOptions["paths"]["*"] = compilerOptions["paths"]["*"] || [
125127
"./node_modules/tns-core-modules/*",
126128
"./node_modules/*"
127129
];
128130
}
129131
}
132+
133+
function getAppPath(projectDir) {
134+
const DEFAULT_PATH = "app";
135+
const nsConfigPath = path.join(projectDir, "nsconfig.json");
136+
137+
let nsConfig;
138+
try {
139+
nsConfig = JSON.parse(fs.readFileSync(nsConfigPath));
140+
const appPath = nsConfig && nsConfig.appPath;
141+
return appPath || DEFAULT_PATH;
142+
} catch(_) {
143+
return DEFAULT_PATH;
144+
}
145+
}

0 commit comments

Comments
 (0)