Skip to content

Commit

Permalink
feat: use @eggjs/utils v4 (#278)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Updated dependency version for improved functionality and potential
new features.
  
- **Bug Fixes**
- Enhanced error handling for better visibility of configuration issues.

- **Documentation**
	- Improved comments for clarity and readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fengmk2 authored Dec 11, 2024
1 parent 20e4ecf commit aedf803
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@artus-cli/artus-cli": "^0.2.9",
"@artus-cli/plugin-autocomplete": "^0.1.1",
"@artus-cli/plugin-version": "^1.0.1",
"@eggjs/utils": "^3.0.1",
"@eggjs/utils": "^4.0.2",
"c8": "^10.0.0",
"detect-port": "^2.0.0",
"egg-ts-helper": "^2.1.0",
Expand Down
14 changes: 9 additions & 5 deletions src/cmd/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,19 @@ export class DevCommand extends BaseCommand {
});

if (!this.port) {
let configuredPort;
let configuredPort: number | undefined;
try {
const configuration = utils.getConfig({
const configuration = await utils.getConfig({
framework: this.framework,
baseDir: this.base,
env: 'local',
});
configuredPort = configuration?.cluster?.listen?.port;
} catch (_) { /** skip when failing to read the configuration */ }

} catch (err) {
/** skip when failing to read the configuration */
debug('getConfig error: %s, framework: %o, baseDir: %o, env: local',
err, this.framework, this.base);
}
if (configuredPort) {
this.port = configuredPort;
debug(`use port ${this.port} from configuration file`);
Expand All @@ -79,7 +82,8 @@ export class DevCommand extends BaseCommand {
debug('detect available port');
this.port = await detect(defaultPort);
if (this.port !== defaultPort) {
console.warn('[egg-bin] server port %s is in use, now using port %o', defaultPort, this.port);
console.warn('[egg-bin] server port %s is in use, now using port %o',
defaultPort, this.port);
}
debug(`use available port ${this.port}`);
}
Expand Down

0 comments on commit aedf803

Please sign in to comment.