Skip to content

Commit 1f49b49

Browse files
committed
Build next version
1 parent d5826a6 commit 1f49b49

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

build/Runner.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class Runner {
3030
const commands = this.config.getCommands(filePath, hook);
3131
const vars = this.getVars(filePath);
3232

33-
return commands.reduce((promise, command) => promise.then(() => this.execute(this.interpolate(command, vars), {
33+
return commands.reduce((promise, command) => promise.then(() => this.execute(this.buildCommand(command, filePath), {
3434
cwd: vars.project,
3535
timeout: 10000 // protect from infinite loops in commands
3636
})), _Promise.resolve());
@@ -53,6 +53,12 @@ export default class Runner {
5353
});
5454
}
5555

56+
buildCommand(command, filePath) {
57+
const vars = this.getVars(filePath);
58+
59+
return this.interpolate(command, vars);
60+
}
61+
5662
/**
5763
* Collects the data related to current file and project
5864
*
@@ -113,6 +119,8 @@ export default class Runner {
113119
* @return {Promise}
114120
*/
115121
execute(command, { timeout, cwd } = {}) {
122+
console.log(`atom-hooks: executing ${command}`);
123+
116124
return new _Promise((resolve, reject) => exec(command, {
117125
cwd,
118126
timeout

build/atom-hooks.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
'use babel';
22

33
import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
4+
import _extends from 'babel-runtime/helpers/extends';
45

56
import { CompositeDisposable } from 'atom';
7+
68
import HooksListView from './views/HooksListView';
79
import StatusView from './views/StatusView';
810
import Config from './Config';
@@ -15,6 +17,9 @@ class AtomHooks {
1517
this.config = new Config();
1618
this.runner = new Runner({ config: this.config });
1719
this.statusView = new StatusView();
20+
this.hooksListView = new HooksListView({
21+
runCommand: (filePath, command) => this.processExecutionResult(this.runner.runCommand(filePath, command))
22+
});
1823

1924
if (!atom.config.get('atom-hooks')) {
2025
atom.config.set('atom-hooks', {
@@ -67,7 +72,7 @@ class AtomHooks {
6772
priority: 100
6873
});
6974

70-
this.statusView.hide(); // do not show till the text editor will be active
75+
this.onChangeActivePane();
7176
}
7277

7378
onChangeActivePane() {
@@ -80,17 +85,17 @@ class AtomHooks {
8085
}
8186
}
8287

83-
onToggleHooksList(filePath) {
84-
if (!this.hooksListView) {
85-
this.hooksListView = new HooksListView({
86-
runCommand: (filePath, command) => this.processExecutionResult(this.runner.runCommand(filePath, command))
87-
});
88-
}
89-
90-
filePath = filePath || this.getCurrentFile();
88+
onToggleHooksList(customFilePath) {
89+
const filePath = customFilePath || this.getCurrentFile();
9190

9291
if (filePath) {
93-
this.hooksListView.show(filePath, this.config.listHooks(filePath));
92+
const availableHooks = this.config.listHooks(filePath).map(hook => {
93+
return _extends({}, hook, {
94+
interpolated: this.runner.buildCommand(hook.command, filePath)
95+
});
96+
});
97+
98+
this.hooksListView.show(filePath, availableHooks);
9499
}
95100
}
96101

build/views/HooksListView.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,22 @@ export default class HooksListView {
1212
if (!this.listView) {
1313
this.listView = new SelectListView({
1414
items: [],
15+
itemsClassList: ['atom-hooks-list-item'],
1516
elementForItem: item => {
1617
const li = document.createElement('li');
17-
li.textContent = `${item.name}: ${item.command}`;
18+
li.classList.add('two-lines');
19+
20+
const primaryLine = document.createElement('div');
21+
primaryLine.textContent = `${item.name}: ${item.command}`;
22+
primaryLine.classList.add('primary-line');
23+
24+
const secondaryLine = document.createElement('div');
25+
secondaryLine.textContent = `${item.interpolated}`;
26+
secondaryLine.classList.add('secondary-line');
27+
28+
li.appendChild(primaryLine);
29+
li.appendChild(secondaryLine);
30+
1831
return li;
1932
},
2033
didConfirmSelection: item => {

build/views/StatusView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class StatusView {
6969
onListHooks(event) {
7070
event.preventDefault();
7171

72-
atom.commands.dispatch(atom.workspace.getCenter().getActivePaneItem().element, 'atom-hooks:show');
72+
atom.commands.dispatch(atom.workspace.element, 'atom-hooks:show');
7373
}
7474

7575
getElement() {

0 commit comments

Comments
 (0)