-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathgetPullRequest.js
More file actions
45 lines (38 loc) · 1.44 KB
/
getPullRequest.js
File metadata and controls
45 lines (38 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/*
ABOUT THIS NODE.JS EXAMPLE: This example works with the AWS SDK for JavaScript version 3 (v3),
which is available at https://github.com/aws/aws-sdk-js-v3. For information about how AWS CodeCommit works,
see https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html.
Purpose:
getPullRequest.js gets information about a pull request in a specified repository.
Inputs (replace in code):
- PULL_REQUEST_ID
Running the code:
node getPullRequest.js
*/
// snippet-start:[codeCommit.JavaScript.getPRv3]
// Get service clients module and commands using ES6 syntax.
import { GetPullRequestCommand } from "@aws-sdk/client-codecommit";
import { codeCommitClient } from "./libs/codeCommitClient.js";
// Set the parameters.
export const params = {
pullRequestId: "PULL_REQUEST_ID",
};
// Get information about the pull request.
export const main = async () => {
try {
const data = await codeCommitClient.send(new GetPullRequestCommand(params));
console.log("Success", data);
return data; // For unit tests.
} catch (err) {
console.log("Error", err);
}
};
// Call a function if this file was run directly. This allows the file
// to be runnable without running on import.
import { fileURLToPath } from "node:url";
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main();
}
// snippet-end:[codeCommit.JavaScript.getPRv3]