Skip to content

Commit b977d2d

Browse files
committed
remove logger
1 parent 504192e commit b977d2d

File tree

2 files changed

+3
-41
lines changed

2 files changed

+3
-41
lines changed

packages/cli/src/logger.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/cli/src/openapi/publish.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as fs from 'fs';
22
import * as api from '@gitbook/api';
33
import { getAPIClient } from '../remote';
4-
import { logger } from '../logger';
54

65
/**
76
* Publish an OpenAPI specification to GitBook from a URL.
@@ -69,35 +68,31 @@ async function readOpenAPIFile(filePath: string): Promise<string> {
6968
return fileContent;
7069
} catch (error) {
7170
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
72-
logger.error(`OpenAPI specification file not found: ${filePath}`);
73-
process.exit(1);
71+
throw new Error(`OpenAPI specification file not found: ${filePath}`);
7472
}
7573
throw error;
7674
}
7775
}
7876

79-
8077
const OPENAPISPEC_SLUG_REGEX = new RegExp(api.OPEN_APISPEC_SLUG_PATTERN);
8178
/**
8279
* Validate the OpenAPI specification slug.
8380
* It should match the pattern and be between the minimum and maximum length.
8481
*/
8582
function validateSlug(specSlug: string) {
8683
if (!OPENAPISPEC_SLUG_REGEX.test(specSlug)) {
87-
logger.error(
84+
throw new Error(
8885
`Invalid OpenAPI specification slug, must match pattern: ${api.OPEN_APISPEC_SLUG_PATTERN}`,
8986
);
90-
process.exit(1);
9187
}
9288

9389
if (
9490
specSlug.length < api.OPEN_APISPEC_SLUG_MIN_LENGTH ||
9591
specSlug.length > api.OPEN_APISPEC_SLUG_MAX_LENGTH
9692
) {
97-
logger.error(
93+
throw new Error(
9894
`Invalid OpenAPI specification slug, must be between ${api.OPEN_APISPEC_SLUG_MIN_LENGTH} and ${api.OPEN_APISPEC_SLUG_MAX_LENGTH} characters`,
9995
);
100-
process.exit(1);
10196
}
10297

10398
return specSlug;

0 commit comments

Comments
 (0)