Skip to content

Commit 0cf00a9

Browse files
committed
implement default-new-contest-cmd global config option
1 parent 119bd73 commit 0cf00a9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/project.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,18 @@ export async function init(contest_id: string, options: { force?: boolean, conte
159159
await saveProjectJSON(data, process.cwd());
160160
console.log(`${dirname}/${PROJECT_JSON_FILE_NAME} created.`);
161161

162+
// --cmdオプションが指定されていない場合はコンフィグよりデフォルト値を取得
163+
const cmd = options.cmd !== undefined? options.cmd : (await getConfig()).get("default-new-contest-cmd") as string | undefined;
162164
// コマンドの実行
163-
if (options.cmd !== undefined) {
164-
console.log(`Command:\n exec \`${options.cmd}\``);
165+
if (cmd !== undefined) {
166+
console.log(`Command:\n exec \`${cmd}\``);
165167
// 環境変数としてパラメータを利用可能にする
166168
const env = {
167169
...process.env,
168170
CONTEST_DIR: process.cwd(),
169171
CONTEST_ID: contest.id
170172
};
171-
const {stdout, stderr} = await promisify(child_process.exec)(options.cmd, {env});
173+
const {stdout, stderr} = await promisify(child_process.exec)(cmd, {env});
172174
if (stdout !== "") console.log(stdout);
173175
if (stderr !== "") console.error(stderr);
174176
}

0 commit comments

Comments
 (0)