Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use @eggjs/utils v4 #278

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading