@@ -23,21 +23,21 @@ Here is a script that records fixtures and logs them to stdout. Run with `GITHUB
2323
2424``` js
2525// my-script.js
26- const { Octokit } = require (" @octokit/core" );
27- const createPullRequest = require (" . " );
28- const MyOctokit = Octokit .plugin (createPullRequest);
26+ const { Octokit } = require (' @octokit/core' )
27+ const createPullRequest = require (' . ' )
28+ const MyOctokit = Octokit .plugin (createPullRequest)
2929const octokit = new MyOctokit ({
3030 auth: process .env .GITHUB_TOKEN ,
31- });
31+ })
3232
33- const fixtures = [];
34- octokit .hook .after (" request" , (response , options ) => {
33+ const fixtures = []
34+ octokit .hook .after (' request' , (response , options ) => {
3535 fixtures .push ({
3636 request: options,
3737 response,
38- });
39- });
40- octokit .hook .error (" request" , (error , options ) => {
38+ })
39+ })
40+ octokit .hook .error (' request' , (error , options ) => {
4141 fixtures .push ({
4242 request: options,
4343 response: {
@@ -48,35 +48,35 @@ octokit.hook.error("request", (error, options) => {
4848 documentation_url: error .documentation_url ,
4949 },
5050 },
51- });
51+ })
5252
53- throw error;
54- });
53+ throw error
54+ })
5555
5656octokit
5757 .createPullRequest ({
58- owner: " gr2m" ,
59- repo: " sandbox" ,
60- title: " One comes, one goes" ,
61- body: " because" ,
62- head: " test-branch-" + Math .random ().toString (36 ).substr (2 , 5 ),
58+ owner: ' gr2m' ,
59+ repo: ' sandbox' ,
60+ title: ' One comes, one goes' ,
61+ body: ' because' ,
62+ head: ` test-branch-${ Math .random ().toString (36 ).substr (2 , 5 )} ` ,
6363 changes: {
6464 files: {
65- " path/to/file1.txt" : " Content for file1" ,
66- " path/to/file2.txt" : " Content for file2" ,
65+ ' path/to/file1.txt' : ' Content for file1' ,
66+ ' path/to/file2.txt' : ' Content for file2' ,
6767 },
68- commit: " why" ,
68+ commit: ' why' ,
6969 },
7070 })
7171
7272 .then (() => {
7373 fixtures .forEach ((fixture ) => {
74- if (fixture .request .headers .authorization ) {
75- fixture .request .headers .authorization = " token secret" ;
76- }
77- });
78- console .log (JSON .stringify (fixtures, null , 2 ));
79- });
74+ if (fixture .request .headers .authorization )
75+ fixture .request .headers .authorization = ' token secret'
76+
77+ })
78+ console .log (JSON .stringify (fixtures, null , 2 ))
79+ })
8080```
8181
8282[ coc ] : ./CODE_OF_CONDUCT.md
0 commit comments