Skip to content

Commit f6a6f33

Browse files
committed
Add port option to user config
1 parent 4d79ea3 commit f6a6f33

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ npx qiita version
224224
設定できるオプションは以下の通りです。
225225

226226
- includePrivate: 限定共有記事を含めるかどうかを選べます。デフォルトは`false`です。
227+
- port: `qiita preview`コマンドで利用するポートを指定できます。デフォルトは`8888`です。
227228

228229
## オプション
229230

src/lib/config.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ describe("config", () => {
224224
beforeEach(() => {
225225
const userConfigData = {
226226
includePrivate: true,
227+
port: 9999,
227228
};
228229
resetFiles();
229230
setFile(userConfigFilePath, JSON.stringify(userConfigData, null, 2));
@@ -233,6 +234,7 @@ describe("config", () => {
233234
const userConfig = await config.getUserConfig();
234235
expect(userConfig).toStrictEqual({
235236
includePrivate: true,
237+
port: 9999,
236238
});
237239
});
238240
});
@@ -246,6 +248,7 @@ describe("config", () => {
246248
const userConfig = await config.getUserConfig();
247249
expect(userConfig).toStrictEqual({
248250
includePrivate: false,
251+
port: 8888,
249252
});
250253
});
251254
});

src/lib/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface Options {
1414

1515
type UserConfig = {
1616
includePrivate: boolean;
17+
port: number;
1718
};
1819

1920
class Config {
@@ -106,6 +107,7 @@ class Config {
106107
async getUserConfig() {
107108
const defaultConfig = {
108109
includePrivate: false,
110+
port: 8888,
109111
} as UserConfig;
110112

111113
if (fsSync.existsSync(this.getUserConfigFilePath())) {

src/server/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AssetsRouter } from "./api/assets";
99
import { EmojiRouter } from "./api/emoji";
1010
import { ItemsRouter } from "./api/items";
1111
import { ReadmeRouter } from "./api/readme";
12+
import { config } from "../lib/config";
1213

1314
export async function startServer() {
1415
const app = express();
@@ -30,9 +31,8 @@ export async function startServer() {
3031
app.use("*", express.static(path.join(__dirname, "../public/index.html")));
3132

3233
const server = createServer(app);
33-
const port = process.env.QIITA_CLI_PORT
34-
? parseInt(process.env.QIITA_CLI_PORT, 10)
35-
: 8888;
34+
const userConfig = await config.getUserConfig();
35+
const port = userConfig.port;
3636
const host = "localhost";
3737

3838
return new Promise<Server>((resolve) => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy