Skip to content

Commit

Permalink
fix(server): Generate help message before using attempting to resolve…
Browse files Browse the repository at this point in the history
… any require statements (#1910)

The `requireOverride` resolves TSServer from the command line arguments.
The `createLogger` import will end up executing this code. As a result,
we need to parse and show the help message before the logger import or
the --help option will fail due to a failure to resolve the TS
dependency.

fixes #1899

(cherry picked from commit 6d3267d)
  • Loading branch information
atscott committed Aug 11, 2023
1 parent de9df94 commit c635f32
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions server/src/server.ts
Expand Up @@ -6,21 +6,21 @@
* found in the LICENSE file at https://angular.io/license
*/

// Parse command line arguments
const options = parseCommandLine(process.argv);

if (options.help) {
console.error(generateHelpMessage(process.argv));
process.exit(0);
}

import {generateHelpMessage, parseCommandLine} from './cmdline_utils';
import {createLogger} from './logger';
import {ServerHost} from './server_host';
import {Session} from './session';
import {resolveNgLangSvc, resolveTsServer} from './version_provider';

function main() {
// Parse command line arguments
const options = parseCommandLine(process.argv);

if (options.help) {
console.error(generateHelpMessage(process.argv));
process.exit(0);
}

// Create a logger that logs to file. OK to emit verbose entries.
const logger = createLogger({
logFile: options.logFile,
Expand Down

0 comments on commit c635f32

Please sign in to comment.