Skip to content

Commit

Permalink
fix: gacm use not work
Browse files Browse the repository at this point in the history
  • Loading branch information
alqmc authored and alqmc committed Nov 9, 2022
1 parent 7fda76b commit 5178486
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 71 deletions.
6 changes: 3 additions & 3 deletions dist/gacm.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const log = {
};

var name$1 = "gacm";
var version$1 = "1.2.2";
var version$1 = "1.2.3";
var description$1 = "gacm";
var scripts = {
build: "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",
Expand Down Expand Up @@ -202,7 +202,7 @@ const printMessages = (messages) => {
};

var name = "gacm";
var version = "1.2.2";
var version = "1.2.3";
var description = "git account manage";
var keywords = [
"git",
Expand Down Expand Up @@ -308,7 +308,7 @@ const useAlias = async (origin, target) => {
await writeFileUser(registriesPath, userList);
};

const useUse = async ([name], cmd) => {
const useUse = async (name, cmd) => {
const userList = await getFileUser(registriesPath);
if (!userList)
return log.error(`no user exists`);
Expand Down
4 changes: 2 additions & 2 deletions dist/gnrm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var prompts__default = /*#__PURE__*/_interopDefaultLegacy(prompts);
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);

var name$1 = "gacm";
var version$1 = "1.2.2";
var version$1 = "1.2.3";
var description$1 = "git account manage";
var keywords = [
"git",
Expand Down Expand Up @@ -82,7 +82,7 @@ const log = {
};

var name = "gacm";
var version = "1.2.2";
var version = "1.2.3";
var description = "gacm";
var scripts = {
build: "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",
Expand Down
4 changes: 2 additions & 2 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gacm",
"version": "1.2.2",
"version": "1.2.3",
"private": false,
"description": "git account manage",
"keywords": [
Expand All @@ -23,4 +23,4 @@
"kolorist": "^1.5.1",
"prompts": "^2.4.2"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gacm",
"version": "1.2.2",
"version": "1.2.3",
"description": "gacm",
"scripts": {
"build": "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",
Expand Down
124 changes: 62 additions & 62 deletions package/commands/gacm/useUse.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
import prompts from 'prompts';
import { registriesPath } from '../../config/path';
import { getFileUser } from '../../utils/getUserList';
import { log } from '../../utils/log';
import { run } from '../../utils/shell';
import type { UserInfo } from '../../type/shell.type';

export interface UseCmd {
local?: boolean;
global?: boolean;
system?: boolean;
}

export const useUse = async ([name]: string[], cmd: UseCmd) => {
const userList = await getFileUser(registriesPath);

if (!userList) return log.error(`no user exists`);

let useUser: UserInfo | undefined = undefined;
if (name) {
useUser = userList.users.find((x) => x.alias === name);
} else {
const { user } = await prompts({
type: 'select',
name: 'user',
message: 'Pick a account',
choices: userList.users.map((x) => {
return {
title: `${x.alias}${x.alias === x.name ? '' : `(${x.name})`} ${
x.email
}`,
value: x,
};
}),
});
if (!user) {
log.error(`user cancel operation`);
return;
}
useUser = user;
}

if (!useUser) return log.error(`${name} not found`);

let env = 'local';

if (cmd.system) env = 'system';

if (cmd.global) env = 'global';

if (cmd.local) env = 'local';

await run(`git config --${env} user.name ${useUser.name}`);

await run(`git config --${env} user.email ${useUser.email}`);

log.success(
`git user changed [${env}]:${useUser.alias}${
useUser.alias !== useUser.name ? `(${useUser.name})` : ''
}`
);
};
import prompts from 'prompts';
import { registriesPath } from '../../config/path';
import { getFileUser } from '../../utils/getUserList';
import { log } from '../../utils/log';
import { run } from '../../utils/shell';
import type { UserInfo } from '../../type/shell.type';

export interface UseCmd {
local?: boolean;
global?: boolean;
system?: boolean;
}

export const useUse = async (name: string, cmd: UseCmd) => {
const userList = await getFileUser(registriesPath);

if (!userList) return log.error(`no user exists`);

let useUser: UserInfo | undefined = undefined;
if (name) {
useUser = userList.users.find((x) => x.alias === name);
} else {
const { user } = await prompts({
type: 'select',
name: 'user',
message: 'Pick a account',
choices: userList.users.map((x) => {
return {
title: `${x.alias}${x.alias === x.name ? '' : `(${x.name})`} ${
x.email
}`,
value: x,
};
}),
});
if (!user) {
log.error(`user cancel operation`);
return;
}
useUser = user;
}

if (!useUser) return log.error(`${name} not found`);

let env = 'local';

if (cmd.system) env = 'system';

if (cmd.global) env = 'global';

if (cmd.local) env = 'local';

await run(`git config --${env} user.name ${useUser.name}`);

await run(`git config --${env} user.email ${useUser.email}`);

log.success(
`git user changed [${env}]:${useUser.alias}${
useUser.alias !== useUser.name ? `(${useUser.name})` : ''
}`
);
};
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gacm",
"version": "1.2.2",
"version": "1.2.3",
"private": false,
"description": "git account manage",
"keywords": [
Expand Down

0 comments on commit 5178486

Please sign in to comment.