Skip to content

Commit 396180c

Browse files
authored
fix: respect nsconfig options when updating tsconfig on postinstall (#61)
fixes #60
1 parent 36a2bf7 commit 396180c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tsconfig-upgrader.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,27 @@ 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+
try {
138+
const nsConfig = JSON.parse(fs.readFileSync(nsConfigPath));
139+
const appPath = nsConfig && nsConfig.appPath;
140+
return appPath || DEFAULT_PATH;
141+
} catch(_) {
142+
return DEFAULT_PATH;
143+
}
144+
}

0 commit comments

Comments
 (0)