55
66import * as vscode from 'vscode' ;
77import * as nls from 'vscode-nls' ;
8- import * as path from 'path' ;
9- import { promises as fs } from 'fs' ;
108import { API as GitAPI , Repository } from './typings/git' ;
119import { getOctokit } from './auth' ;
10+ import { TextEncoder } from 'util' ;
1211
1312const localize = nls . loadMessageBundle ( ) ;
1413
@@ -106,9 +105,7 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
106105 try {
107106 quickpick . busy = true ;
108107
109- const repositoryPath = folder . uri . fsPath ;
110- const currentPath = path . join ( repositoryPath ) ;
111- const children = await fs . readdir ( currentPath ) ;
108+ const children = ( await vscode . workspace . fs . readDirectory ( folder . uri ) ) . map ( ( [ name ] ) => name ) ;
112109 quickpick . items = children . map ( name => ( { label : name } ) ) ;
113110 quickpick . selectedItems = quickpick . items ;
114111 quickpick . busy = false ;
@@ -126,7 +123,8 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
126123 result . forEach ( c => ignored . delete ( c . label ) ) ;
127124
128125 const raw = [ ...ignored ] . map ( i => `/${ i } ` ) . join ( '\n' ) ;
129- await fs . writeFile ( path . join ( repositoryPath , '.gitignore' ) , raw , 'utf8' ) ;
126+ const encoder = new TextEncoder ( ) ;
127+ await vscode . workspace . fs . writeFile ( vscode . Uri . joinPath ( folder . uri , '.gitignore' ) , encoder . encode ( raw ) ) ;
130128 } finally {
131129 quickpick . dispose ( ) ;
132130 }
0 commit comments