11#!/usr/bin/env node
22"use strict" ;
3+
34const { parse, resolve } = require ( "path" ) ;
5+ const fs = require ( "fs" ) ;
46
57const sharp = require ( "sharp" ) ;
68const execa = require ( "execa" ) ;
@@ -10,7 +12,7 @@ const meow = require("meow");
1012const got = require ( "got" ) ;
1113const cp = require ( "cp-file" ) ;
1214
13- const { cloneGistPath, addAll , commitAll, push } = require ( "./git-util" ) ;
15+ const { cloneGistPath, commitAll, push } = require ( "./git-util" ) ;
1416
1517const CONTAINER_WIDTH = 727 ;
1618const CUT_WIDTH = 325 ;
@@ -147,14 +149,21 @@ const crop = async (path, githubToken) => {
147149 body
148150 } ) ;
149151 const data = JSON . parse ( res ) ;
150- console . log ( `Gist for ${ file } has been created in ${ data . html_url } ` ) ;
152+ console . log ( `Prepared the gist for ${ file } in ${ data . html_url } ` ) ;
151153 await cloneGistPath ( data . id ) ;
152154 await cp ( file , `${ data . id } /${ file } ` ) ;
153155 const gitPath = resolve ( `./${ data . id } /.git` ) ;
154- await addAll ( gitPath ) ;
155156 await commitAll ( gitPath ) ;
157+ fs . writeFileSync (
158+ `${ data . id } /.netrc` ,
159+ `machine github.com\nlogin ${
160+ data . owner . login
161+ } \npassword ${ githubToken } `
162+ ) ;
156163 await push ( gitPath ) ;
157- console . log ( `${ isGif ? "GIF" : "Image" } has been added to the gist` ) ;
164+ console . log (
165+ `${ isGif ? "GIF" : "Image" } ${ file } has been added to the gist`
166+ ) ;
158167 }
159168 } catch ( e ) {
160169 console . error ( e ) ;
0 commit comments