@@ -14,7 +14,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
1414var execa__default = /*#__PURE__*/ _interopDefaultLegacy ( execa ) ;
1515
1616var name = "gacm" ;
17- var version$1 = "1.0.0 " ;
17+ var version$1 = "1.0.1 " ;
1818var description = "git account manage" ;
1919var keywords = [
2020 "git" ,
@@ -69,15 +69,19 @@ const baseAction = async (cmd) => {
6969} ;
7070
7171const rootPath = __dirname ;
72- const outputPath = __dirname ;
72+ __dirname ;
7373path . resolve ( rootPath , "package" ) ;
74- const registriesPath = path . resolve ( outputPath , "registries.json" ) ;
74+ const HOME = process . env [ process . platform === "win32" ? "USERPROFILE" : "HOME" ] || "" ;
75+ const registriesPath = path . join ( HOME , ".gacmrc" ) ;
7576
7677const { readFile, writeFile } = fs . promises ;
7778const getFileUser = async ( rootPath ) => {
78- const fileBuffer = await readFile ( rootPath , "utf-8" ) ;
79- const userList = fileBuffer ? JSON . parse ( fileBuffer . toString ( ) ) : null ;
80- return userList ;
79+ if ( fs . existsSync ( rootPath ) ) {
80+ const fileBuffer = await readFile ( rootPath , "utf-8" ) ;
81+ const userList = fileBuffer ? JSON . parse ( fileBuffer . toString ( ) ) : null ;
82+ return userList ;
83+ }
84+ return null ;
8185} ;
8286async function writeFileUser ( dir , data ) {
8387 writeFile ( dir , JSON . stringify ( data , null , 4 ) ) . catch ( ( error ) => {
@@ -185,7 +189,7 @@ const deleteAction = async (name) => {
185189 if ( ! userList [ name ] )
186190 return log . error ( `${ name } not found` ) ;
187191 delete userList [ name ] ;
188- await writeFileUser ( path . resolve ( outputPath , `registries.json` ) , userList ) ;
192+ await writeFileUser ( registriesPath , userList ) ;
189193 log . success ( `[delete]: ${ name } ` ) ;
190194} ;
191195const insertUser = async ( name , email ) => {
@@ -196,7 +200,7 @@ const insertUser = async (name, email) => {
196200 name,
197201 email
198202 } ;
199- await writeFileUser ( path . resolve ( outputPath , `registries.json` ) , userList ) ;
203+ await writeFileUser ( registriesPath , userList ) ;
200204} ;
201205
202206const program = new commander . Command ( ) ;
0 commit comments