@@ -31,7 +31,12 @@ function _copy(from: string, to: string) {
3131}
3232
3333
34- export default function ( opts : { force ?: boolean , githubToken : string } , logger : logging . Logger ) {
34+ export interface SnapshotsOptions {
35+ force ?: boolean ;
36+ githubTokenFile : string ;
37+ }
38+
39+ export default function ( opts : SnapshotsOptions , logger : logging . Logger ) {
3540 // Get the SHA.
3641 if ( execSync ( `git status --porcelain` ) . toString ( ) && ! opts . force ) {
3742 logger . error ( 'You cannot run snapshots with local changes.' ) ;
@@ -41,6 +46,8 @@ export default function(opts: { force?: boolean, githubToken: string }, logger:
4146 const root = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'angular-devkit-publish-' ) ) ;
4247 const message = execSync ( `git log --format="%h %s" -n1` ) . toString ( ) . trim ( ) ;
4348
49+ const githubToken = fs . readFileSync ( opts . githubTokenFile , 'utf-8' ) ;
50+
4451 // Run build.
4552 logger . info ( 'Building...' ) ;
4653 build ( { snapshot : true } , logger . createChild ( 'build' ) ) ;
@@ -65,8 +72,7 @@ export default function(opts: { force?: boolean, githubToken: string }, logger:
6572 _copy ( pkg . dist , destPath ) ;
6673
6774 execSync ( `git config credential.helper "store --file=.git/credentials"` , { cwd : destPath } ) ;
68- fs . writeFileSync ( path . join ( destPath , '.git/credentials' ) ,
69- `https://${ opts . githubToken } @github.com` ) ;
75+ fs . writeFileSync ( path . join ( destPath , '.git/credentials' ) , `https://${ githubToken } @github.com` ) ;
7076
7177 // Make sure that every snapshots is unique.
7278 fs . writeFileSync ( path . join ( destPath , 'uniqueId' ) , '' + new Date ( ) ) ;
0 commit comments