@@ -5,7 +5,6 @@ import trim from 'lodash/trim';
55import performWithRetries from '../util/performWithRetries' ;
66import compileProject from '../util/compileProject' ;
77
8- const anonymousGithub = new GitHub ( { } ) ;
98const COMMIT_MESSAGE = 'Created using Popcode: https://popcode.org' ;
109const MASTER = 'master' ;
1110const GH_PAGES = 'gh-pages' ;
@@ -70,11 +69,7 @@ export async function createGistFromProject(project, user) {
7069 const response =
7170 await performWithRetryNetworkErrors ( ( ) => github . getGist ( ) . create ( gist ) ) ;
7271
73- const gistData = response . data ;
74- if ( canUpdateGist ( user ) ) {
75- return updateGistWithImportUrl ( github , gistData ) ;
76- }
77- return gistData ;
72+ return updateGistWithImportUrl ( github , response . data ) ;
7873}
7974
8075export async function loadGistFromId ( gistId , user ) {
@@ -253,19 +248,7 @@ function githubWithAccessToken(token) {
253248 return new GitHub ( { auth : 'oauth' , token} ) ;
254249}
255250
256- function getGithubToken ( user ) {
257- return get ( user , [ 'accessTokens' , 'github.com' ] ) ;
258- }
259-
260251function clientForUser ( user ) {
261- const githubToken = getGithubToken ( user ) ;
262- if ( githubToken ) {
263- return githubWithAccessToken ( githubToken ) ;
264- }
265-
266- return anonymousGithub ;
267- }
268-
269- function canUpdateGist ( user ) {
270- return Boolean ( getGithubToken ( user ) ) ;
252+ const githubToken = get ( user , [ 'accessTokens' , 'github.com' ] ) ;
253+ return githubWithAccessToken ( githubToken ) ;
271254}
0 commit comments