Skip to content

Commit

Permalink
Merge pull request #216 from Tencent/fix/auto-update
Browse files Browse the repository at this point in the history
fix: auto update
  • Loading branch information
fXy-during authored Apr 14, 2020
2 parents d7d681b + 33f9b94 commit c2cfd95
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/feflow-cli/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@ export default class Feflow {
}
const packageManager = config.packageManager;
const autoUpdate = args['auto-update'] || config.autoUpdate === 'true';
if (autoUpdate) {
return await this.updateCli(packageManager);
}
if (config.lastUpdateCheck && (+new Date() - parseInt(config.lastUpdateCheck, 10)) <= 1000 * 3600 * 24) {
return;
}
Expand All @@ -346,7 +343,13 @@ export default class Feflow {
this.logger.warn(`Network error, can't reach ${ registryUrl }, CLI give up verison check.`);
});

this.logger.debug(`Auto update: ${autoUpdate}`);
if (latestVersion && semver.gt(latestVersion, version)) {
this.logger.debug(`Find new version, current version: ${version}, latest version: ${autoUpdate}`);
if (autoUpdate) {
this.logger.debug(`Auto update version from ${version} to ${latestVersion}`);
return await this.updateCli(packageManager);
}
const askIfUpdateCli = [{
type: "confirm",
name: "ifUpdate",
Expand All @@ -362,6 +365,8 @@ export default class Feflow {
'lastUpdateCheck': +new Date()
}, configPath);
}
} else {
this.logger.debug(`Current version is already latest.`);
}
}

Expand Down

0 comments on commit c2cfd95

Please sign in to comment.