Skip to content

Commit f5a893d

Browse files
committed
Add cross-spawn to dependencies and code organization
1 parent a926cb8 commit f5a893d

File tree

6 files changed

+36
-39
lines changed

6 files changed

+36
-39
lines changed

package-lock.json

Lines changed: 6 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,14 @@
9595
"lint": "prettier --check \"src/**/*.{ts,js,json}\"",
9696
"format": "prettier --write \"src/**/*.{ts,js,json}\""
9797
},
98+
"dependencies": {
99+
"cross-spawn": "^7.0.1"
100+
},
98101
"devDependencies": {
99102
"@types/cross-spawn": "^6.0.1",
100103
"@types/glob": "^7.1.1",
101104
"@types/mocha": "^5.2.7",
102105
"@types/node": "^12.11.1",
103-
"cross-spawn": "^7.0.1",
104106
"glob": "^7.1.4",
105107
"mocha": "^6.2.2",
106108
"prettier": "^1.18.2",

src/GradeTreeItem.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ import {
77
import path from 'path';
88

99
export default class GradleTreeItem extends TreeItem {
10-
constructor(
11-
public readonly context: ExtensionContext,
12-
public readonly label: string,
13-
public readonly collapsibleState: TreeItemCollapsibleState,
14-
public readonly tooltip: string,
15-
public readonly command?: Command
16-
) {
17-
super(label, collapsibleState);
18-
}
1910
contextValue = 'script';
2011
iconPath = {
2112
light: this.context.asAbsolutePath(
@@ -25,4 +16,13 @@ export default class GradleTreeItem extends TreeItem {
2516
path.join('resources', 'dark', 'script.svg')
2617
)
2718
};
19+
constructor(
20+
public readonly context: ExtensionContext,
21+
public readonly label: string,
22+
public readonly collapsibleState: TreeItemCollapsibleState,
23+
public readonly tooltip: string,
24+
public readonly command?: Command
25+
) {
26+
super(label, collapsibleState);
27+
}
2828
}

src/Gradle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ function runTask(
2929
task: GradleTask,
3030
outputChannel: OutputChannel
3131
): Promise<string> {
32-
const cmd = getCommand();
33-
const args = [task.label];
34-
const options = { cwd: workspace.rootPath };
3532
const statusbar: Disposable = window.setStatusBarMessage(
3633
'Running gradle task'
3734
);
35+
const cmd = getCommand();
36+
const args = [task.label];
37+
const options = { cwd: workspace.rootPath };
3838

3939
outputChannel.show();
4040
outputChannel.append(`Running ${cmd} ${task.label}\n`);

src/GradleNodeProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import TaskRegistry from './TaskRegistry';
1111
import GradleTreeItem from './GradeTreeItem';
1212

1313
export default class TreeProvider implements TreeDataProvider<GradleTreeItem> {
14-
private _onDidChangeTreeData: EventEmitter<GradleTreeItem> = new EventEmitter<
14+
private readonly _onDidChangeTreeData: EventEmitter<
1515
GradleTreeItem
16-
>();
16+
> = new EventEmitter<GradleTreeItem>();
17+
1718
readonly onDidChangeTreeData: Event<GradleTreeItem> = this
1819
._onDidChangeTreeData.event;
1920

src/extension.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ async function gradleRunTaskCommand(
4848
export async function activate(context: ExtensionContext) {
4949
outputChannel = window.createOutputChannel('Gradle');
5050

51+
context.subscriptions.push(
52+
commands.registerCommand('gradle:refresh', gradleRefreshTasksCommand)
53+
);
54+
context.subscriptions.push(
55+
commands.registerCommand('gradle:runtask', gradleRunTaskCommand)
56+
);
57+
context.subscriptions.push(
58+
commands.registerCommand('gradle:kill', gradleKillCommand)
59+
);
60+
61+
await commands.executeCommand('gradle:refresh');
62+
5163
workspace
5264
.createFileSystemWatcher('/build.gradle')
5365
.onDidChange(gradleRefreshTasksCommand);
@@ -56,24 +68,12 @@ export async function activate(context: ExtensionContext) {
5668
.getConfiguration()
5769
.get('gradle.enableTasksExplorer');
5870

59-
await gradleRefreshTasksCommand();
60-
6171
if (explorerEnabled) {
6272
const treeProvider: GradleTreeProvider = new GradleTreeProvider(context);
6373
TaskRegistry.registerChangeHandler(() => treeProvider.refresh());
6474
window.registerTreeDataProvider('gradleTasks', treeProvider);
6575
}
6676

67-
context.subscriptions.push(
68-
commands.registerCommand('gradle:refresh', gradleRefreshTasksCommand)
69-
);
70-
context.subscriptions.push(
71-
commands.registerCommand('gradle:runtask', gradleRunTaskCommand)
72-
);
73-
context.subscriptions.push(
74-
commands.registerCommand('gradle:kill', gradleKillCommand)
75-
);
76-
7777
commands.executeCommand('setContext', 'gradleTasksExtensionActive', true);
7878

7979
return {

0 commit comments

Comments
 (0)