Skip to content

Commit 3bea136

Browse files
authored
feat: opens the URL in a specified browser (#2)
1 parent 44bef6c commit 3bea136

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ yarn add create-pull-request --global
1717
## Usage
1818

1919
```
20-
// in the terminal in your project folder
20+
// in the terminal in your project folder (default browser)
2121
create-pull-request
2222
```
2323

24+
```
25+
// opens the URL in a specified browser
26+
create-pull-request firefox
27+
```
28+
2429
It will open an URL to create a new pull request pointing to the base branch.
2530

2631
e.g.
@@ -36,4 +41,4 @@ Pull requests are welcome. For major changes, please open an issue first to disc
3641

3742
## License
3843

39-
[MIT](https://choosealicense.com/licenses/mit/)
44+
This project is open source and available under the: [MIT License](LICENSE)

create-pull-request.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,27 @@ const open = require("open");
1111
throw stderr;
1212
}
1313

14+
const browsers = [
15+
{ id: "chrome", value: "chrome" },
16+
{ id: "firefox", value: "firefox" },
17+
{ id: "edge", value: "msedge" },
18+
{ id: "safari", value: "safari" },
19+
{ id: "ie", value: "iexplore" },
20+
{ id: "opera", value: "opera" }
21+
];
22+
1423
const branchName = stdout.trim();
1524
const remoteOriginUrl = await gitRemoteOriginUrl();
1625
const newPullRequestUrl = `https://${remoteOriginUrl.replace("git@", "").replace(":", "/").replace(/\.git$/, "")}/pull/new/${branchName}`;
26+
let [,, browser = ""] = process.argv;
27+
28+
if (browser) {
29+
browser = browsers.find(({ id }) => id == browser.toLowerCase());
30+
browser = browser ? browser.value : "";
31+
}
1732

18-
await open(newPullRequestUrl);
33+
await open(newPullRequestUrl, {app: browser});
1934
} catch (error) {
2035
throw error;
2136
}
22-
})();
37+
})();

0 commit comments

Comments
 (0)