forked from microsoft/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewPR.ts
More file actions
19 lines (17 loc) · 719 Bytes
/
Copy pathnewPR.ts
File metadata and controls
19 lines (17 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { stat as statCb, writeFile as writeFileCb } from 'fs';
import { promisify } from 'util';
import { IPullRequestManager } from '../github/interface';
import { join } from 'path';
const writeFile = promisify(writeFileCb);
const stat = promisify(statCb);
const exists = file => stat(file).catch(() => null);
const mdPath = uri => join(uri.fsPath, '.git', 'PULL_REQUEST.md');
export const findOrCreatePRMarkdown = async (manager: IPullRequestManager): Promise<string> => {
const root = manager.repository.rootUri;
const path = mdPath(root);
if (!await exists(path)) {
const {title, body} = await manager.getPullRequestDefaults();
await writeFile(path, `title: ${title}\n---\n${body}\n`);
}
return path;
};