Skip to content

Commit

Permalink
fix: Slow installation #483 (#485)
Browse files Browse the repository at this point in the history
* fix: bump minor node version

* fix: slow install
  • Loading branch information
jiro4989 authored Jun 29, 2024
1 parent 082a977 commit 2af8a1a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.10.0
20.15.0
14 changes: 13 additions & 1 deletion lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,18 @@ function installNim(version, noColor, yes) {
// #38
if (util.isGlobPatchVersion(version) || util.isGlobMinorVersion(version)) {
core.info(`Fetch a latest versions with ${version}`);
const beginDate = Date.now();
version = yield util.getLatestVersion(version);
const endDate = Date.now();
const elapsed = endDate - beginDate;
core.info(`Succeeded to fetch version: version = ${version} elapsed = ${elapsed} millisecond`);
}
// #483
// なぜか init.sh を実行したときに 2.x 以降のバージョンをインストールしようとすると非常に遅い。
// しかし 1.x を一度インストールしてから 2.x に切り替える場合は高速に完了するため、一旦その方法で回避する。
process.env.CHOOSENIM_CHOOSE_VERSION = "1.6.0";
// #21
if (process.platform === 'win32') {
process.env.CHOOSENIM_CHOOSE_VERSION = version;
proc.execFile('bash', ['init.sh', '-y'], (err, stdout, stderr) => {
if (err) {
core.error(err);
Expand All @@ -92,12 +99,17 @@ function installNim(version, noColor, yes) {
});
return;
}
const beginDate = Date.now();
core.info(`Run init.sh`);
proc.execFile('bash', ['init.sh', '-y'], (err, stdout, stderr) => {
if (err) {
core.error(err);
throw err;
}
const endDate = Date.now();
const elapsed = endDate - beginDate;
core.info(stdout);
core.info(`Succeeded to run init.sh: elapsed = ${elapsed} millisecond`);
// Build optional parameters of choosenim.
let args = util.parseVersion(version);
if (noColor)
Expand Down
27 changes: 21 additions & 6 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ async function installNim(version: string, noColor: boolean, yes: boolean) {
// #38
if (util.isGlobPatchVersion(version) || util.isGlobMinorVersion(version)) {
core.info(`Fetch a latest versions with ${version}`)
const beginDate = Date.now()
version = await util.getLatestVersion(version)
const endDate = Date.now()
const elapsed = endDate - beginDate
core.info(
`Succeeded to fetch version: version = ${version} elapsed = ${elapsed} millisecond`,
)
}

// #483
// なぜか init.sh を実行したときに 2.x 以降のバージョンをインストールしようとすると非常に遅い。
// しかし 1.x を一度インストールしてから 2.x に切り替える場合は高速に完了するため、一旦その方法で回避する。
process.env.CHOOSENIM_CHOOSE_VERSION = '1.6.0'

// #21
if (process.platform === 'win32') {
process.env.CHOOSENIM_CHOOSE_VERSION = version
proc.execFile(
'bash',
['init.sh', '-y'],
Expand Down Expand Up @@ -63,15 +73,17 @@ async function installNim(version: string, noColor: boolean, yes: boolean) {
throw err
}
core.info(stdout)
}
},
)
}
},
)
}
},
)
return
}

const beginDate = Date.now()
core.info(`Run init.sh`)
proc.execFile(
'bash',
['init.sh', '-y'],
Expand All @@ -80,7 +92,10 @@ async function installNim(version: string, noColor: boolean, yes: boolean) {
core.error(err)
throw err
}
const endDate = Date.now()
const elapsed = endDate - beginDate
core.info(stdout)
core.info(`Succeeded to run init.sh: elapsed = ${elapsed} millisecond`)

// Build optional parameters of choosenim.
let args: string[] = util.parseVersion(version)
Expand All @@ -96,8 +111,8 @@ async function installNim(version: string, noColor: boolean, yes: boolean) {
throw err
}
core.info(stdout)
}
},
)
}
},
)
}
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function fetchTagList(): Promise<any> {
*/
export function getLatestVersionWithTags(
version: string,
tags: string[]
tags: string[],
): string {
if (!isGlobPatchVersion(version) && !isGlobMinorVersion(version)) {
return ''
Expand Down

0 comments on commit 2af8a1a

Please sign in to comment.