Skip to content

Commit 8fabf06

Browse files
committed
refactor(command): action函数参数改为解构赋值使用
1 parent a614409 commit 8fabf06

File tree

7 files changed

+8
-20
lines changed

7 files changed

+8
-20
lines changed

command/delete.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ export const deleteCommand = new Command('delete')
77
.description('delete remote file')
88
.argument('<remote>', 'remote path')
99
.option('-t --token <token>', 'access token', '')
10-
.action(async (remote, options, command) => {
11-
const { pcs } = command;
12-
10+
.action(async (remote, options, { pcs }) => {
1311
if (pcs.resolve(remote) === pcs.resolve('/')) {
1412
console.log(chalk.red('You are about to delete the root directory of the application, which will lose all data'));
1513
const { confirm } = await prompts({

command/download.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export const downloadCommand = new Command('download')
99
.argument('[remote]', 'remote path', sep)
1010
.argument('[local]', 'local path', '.')
1111
.option('-t --token <token>', 'access token', '')
12-
.action(async (remote, local, options, command) => {
13-
const { pcs } = command;
14-
12+
.action(async (remote, local, options, { pcs }) => {
1513
try {
1614
const { list } = await pcs.list(remote);
1715

command/fetch.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export const fetchCommand = new Command('fetch')
88
.argument('[source]', 'source path', sep)
99
.argument('[remote]', 'remote path', '.')
1010
.option('-t --token <token>', 'access token', '')
11-
.action(async (source, remote, options, command) => {
12-
const { pcs } = command;
13-
11+
.action(async (source, remote, options, { pcs }) => {
1412
try {
1513
await pcs.fetch(source, remote);
1614
} catch (err: any) {

command/list.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export const listCommand = new Command('list')
99
.argument('[path]', 'path', '/')
1010
.alias('ll')
1111
.option('-t --token <token>', 'access token', '')
12-
.action(async (path, options, command) => {
13-
const { pcs } = command;
14-
12+
.action(async (path, options, { pcs }) => {
1513
try {
1614
const ui = cliui({} as any);
1715

command/meta.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ export const metaCommand = new Command('meta')
55
.description('get path meta')
66
.argument('[path]', 'meta path', '/')
77
.option('-t --token [token]', 'access token')
8-
.action(async (path, options, command) => {
9-
const { pcs } = command;
10-
8+
.action(async (path, options, { pcs }) => {
119
try {
1210
const { list } = await pcs.meta(path);
1311
console.log(list[0]);

command/quota.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Progress from 'progress';
66
export const quotaCommand = new Command('quota')
77
.description('check your pcs status')
88
.option('-t --token [token]', 'access token')
9-
.action(async (options, command) => {
10-
const { pcs } = command;
11-
9+
.action(async (options, { pcs }) => {
1210
try {
1311
const { quota, used } = await pcs.quota();
1412
const bar = new Progress(':bar :used/:quota :percent', {

scripts/prepublish.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import pkg from '../package.json' with { type: 'json' };
99
const __filename = fileURLToPath(import.meta.url);
1010
const __dirname = path.dirname(__filename);
1111

12-
const packageJsonPath = path.join(__dirname, '../package.json');
12+
const pkgPath = path.join(__dirname, '../package.json');
1313

1414
// 修改 bin 字段
1515
pkg.bin.pcs = 'dist/pcs.js';
1616

17-
fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2));
17+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));

0 commit comments

Comments
 (0)