Skip to content

Commit 80e3d05

Browse files
authored
perf: improve memory efficiency and performance (#29)
1 parent d10ef81 commit 80e3d05

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

bin/completion-handlers.ts

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// TODO: i do not see any completion functionality in this file. nothing is being provided for the defined commands of these package managers. this is a blocker for release. every each of them should be handled.
22
import { Completion } from '../src/index.js';
33

4+
const noopCompletion = async () => [];
5+
46
export function setupCompletionForPackageManager(
57
packageManager: string,
68
completion: Completion
@@ -20,50 +22,49 @@ export function setupCompletionForPackageManager(
2022
}
2123

2224
export function setupPnpmCompletions(completion: Completion) {
23-
completion.addCommand('add', 'Install a package', [], async () => []);
24-
completion.addCommand('remove', 'Remove a package', [], async () => []);
25+
completion.addCommand('add', 'Install a package', [], noopCompletion);
26+
completion.addCommand('remove', 'Remove a package', [], noopCompletion);
2527
completion.addCommand(
2628
'install',
2729
'Install all dependencies',
2830
[],
29-
async () => []
31+
noopCompletion
3032
);
31-
// TODO: empty functions should be replaced with noop functions rather than creating that many empty functions
32-
completion.addCommand('update', 'Update packages', [], async () => []);
33-
completion.addCommand('exec', 'Execute a command', [], async () => []);
34-
completion.addCommand('run', 'Run a script', [], async () => []);
35-
completion.addCommand('publish', 'Publish package', [], async () => []);
36-
completion.addCommand('test', 'Run tests', [], async () => []);
37-
completion.addCommand('build', 'Build project', [], async () => []);
33+
completion.addCommand('update', 'Update packages', [], noopCompletion);
34+
completion.addCommand('exec', 'Execute a command', [], noopCompletion);
35+
completion.addCommand('run', 'Run a script', [], noopCompletion);
36+
completion.addCommand('publish', 'Publish package', [], noopCompletion);
37+
completion.addCommand('test', 'Run tests', [], noopCompletion);
38+
completion.addCommand('build', 'Build project', [], noopCompletion);
3839
}
3940

4041
export function setupNpmCompletions(completion: Completion) {
41-
completion.addCommand('install', 'Install a package', [], async () => []);
42-
completion.addCommand('uninstall', 'Uninstall a package', [], async () => []);
43-
completion.addCommand('run', 'Run a script', [], async () => []);
44-
completion.addCommand('test', 'Run tests', [], async () => []);
45-
completion.addCommand('publish', 'Publish package', [], async () => []);
46-
completion.addCommand('update', 'Update packages', [], async () => []);
47-
completion.addCommand('start', 'Start the application', [], async () => []);
48-
completion.addCommand('build', 'Build project', [], async () => []);
42+
completion.addCommand('install', 'Install a package', [], noopCompletion);
43+
completion.addCommand('uninstall', 'Uninstall a package', [], noopCompletion);
44+
completion.addCommand('run', 'Run a script', [], noopCompletion);
45+
completion.addCommand('test', 'Run tests', [], noopCompletion);
46+
completion.addCommand('publish', 'Publish package', [], noopCompletion);
47+
completion.addCommand('update', 'Update packages', [], noopCompletion);
48+
completion.addCommand('start', 'Start the application', [], noopCompletion);
49+
completion.addCommand('build', 'Build project', [], noopCompletion);
4950
}
5051

5152
export function setupYarnCompletions(completion: Completion) {
52-
completion.addCommand('add', 'Add a package', [], async () => []);
53-
completion.addCommand('remove', 'Remove a package', [], async () => []);
54-
completion.addCommand('run', 'Run a script', [], async () => []);
55-
completion.addCommand('test', 'Run tests', [], async () => []);
56-
completion.addCommand('publish', 'Publish package', [], async () => []);
57-
completion.addCommand('install', 'Install dependencies', [], async () => []);
58-
completion.addCommand('build', 'Build project', [], async () => []);
53+
completion.addCommand('add', 'Add a package', [], noopCompletion);
54+
completion.addCommand('remove', 'Remove a package', [], noopCompletion);
55+
completion.addCommand('run', 'Run a script', [], noopCompletion);
56+
completion.addCommand('test', 'Run tests', [], noopCompletion);
57+
completion.addCommand('publish', 'Publish package', [], noopCompletion);
58+
completion.addCommand('install', 'Install dependencies', [], noopCompletion);
59+
completion.addCommand('build', 'Build project', [], noopCompletion);
5960
}
6061

6162
export function setupBunCompletions(completion: Completion) {
62-
completion.addCommand('add', 'Add a package', [], async () => []);
63-
completion.addCommand('remove', 'Remove a package', [], async () => []);
64-
completion.addCommand('run', 'Run a script', [], async () => []);
65-
completion.addCommand('test', 'Run tests', [], async () => []);
66-
completion.addCommand('install', 'Install dependencies', [], async () => []);
67-
completion.addCommand('update', 'Update packages', [], async () => []);
68-
completion.addCommand('build', 'Build project', [], async () => []);
63+
completion.addCommand('add', 'Add a package', [], noopCompletion);
64+
completion.addCommand('remove', 'Remove a package', [], noopCompletion);
65+
completion.addCommand('run', 'Run a script', [], noopCompletion);
66+
completion.addCommand('test', 'Run tests', [], noopCompletion);
67+
completion.addCommand('install', 'Install dependencies', [], noopCompletion);
68+
completion.addCommand('update', 'Update packages', [], noopCompletion);
69+
completion.addCommand('build', 'Build project', [], noopCompletion);
6970
}

0 commit comments

Comments
 (0)