Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d5b5b83

Browse filesBrowse files
author
Alexander Vakrilov
authored
Merge pull request #68 from NativeScript/ts-update-patch
chore: TS force install patches
2 parents 814d533 + 7424564 commit d5b5b83
Copy full SHA for d5b5b83

1 file changed

+13-13Lines changed: 13 additions & 13 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎postinstall.js‎

Copy file name to clipboardExpand all lines: postinstall.js
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (projectDir) {
1919
createReferenceFile();
2020
}
2121

22-
installTypescript(hasModules30);
22+
installTypescript();
2323
}
2424

2525
function createReferenceFile() {
@@ -63,16 +63,14 @@ function getProjectTypeScriptVersion() {
6363
}
6464
}
6565

66-
function installTypescript(hasModules30) {
66+
function installTypescript() {
6767
const installedTypeScriptVersion = getProjectTypeScriptVersion();
68-
const force = shouldInstallLatest(installedTypeScriptVersion, hasModules30);
68+
const force = shouldInstallLatest(installedTypeScriptVersion);
6969

7070
if (installedTypeScriptVersion && !force) {
7171
console.log(`Project already targets TypeScript ${installedTypeScriptVersion}`);
7272
} else {
73-
const command = force ?
74-
"npm install -D typescript@latest" :
75-
"npm install -D -E typescript@2.1.6"; // install exactly 2.1.6
73+
const command = "npm install -D typescript@latest";
7674

7775
console.log("Installing TypeScript...");
7876

@@ -87,16 +85,18 @@ function installTypescript(hasModules30) {
8785
}
8886
}
8987

90-
function shouldInstallLatest(tsVersion, hasModules30) {
91-
if (!hasModules30) {
92-
return false;
88+
function shouldInstallLatest(tsVersion) {
89+
if (!tsVersion) {
90+
return true;
9391
}
9492

9593
const justVersion = clearPatch(tsVersion);
96-
return !tsVersion ||
97-
tsVersion === "2.2.0" ||
98-
justVersion[0] < 2 || // ex. 1.8.10
99-
justVersion[2] < 2; // ex. 2.1.6
94+
const majorVer = justVersion[0];
95+
const minorVer = justVersion[2];
96+
97+
return tsVersion === "2.2.0" ||
98+
majorVer < 2 || // ex. 1.8.10
99+
(majorVer === "2" && minorVer < 2); // ex. 2.1.6
100100
}
101101

102102
function clearPatch(version) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.