Skip to content

Commit da74db8

Browse files
committed
Prepares 0.2.0 release
2 parents 800561a + cdedce6 commit da74db8

13 files changed

+316
-260
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ All notable changes to the Adobe Script Runner extension will be documented in t
66

77
## Released
88

9+
## [0.2.0] 2018-03-29
10+
11+
- Fixed bug when settings were not registered until app restart.
12+
- Fixed issue with HOME "~/" paths.
13+
- Changed code flow. Splits everything to modules for easier maintenance and development. Also makes it easier for other apps to adopt the functionality.
14+
- Ports functionality to [Atom.io](https://atom.io/packages/adobe-script-runner).
15+
916
## [0.1.2] 2018-03-14
1017

1118
### Added

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Adobe Script Runner
2-
Script runner for Adobe applications right from VSCode.
2+
3+
Script runner for Adobe applications right from VSCode. Extension also available for [Atom.io](https://atom.io/packages/adobe-script-runner).
34

45
![Adobe Script Runner](/resources/Adobe-Script-Runner.gif)
56

extension.js

Lines changed: 0 additions & 257 deletions
This file was deleted.

lib/config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const vscode = require('vscode');
2+
3+
function update() {
4+
return vscode.workspace.getConfiguration('adobeScriptRunner');
5+
}
6+
7+
module.exports.update = update;

lib/editor.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const vscode = require('vscode');
2+
3+
const editor = {
4+
getActiveTextEditor() {
5+
return vscode.window.activeTextEditor;
6+
},
7+
8+
hasPath(activeTextEditor) {
9+
return !activeTextEditor.document.isUntitled;
10+
},
11+
12+
isDirty(activeTextEditor) {
13+
return activeTextEditor.document.isDirty && this.hasPath(activeTextEditor);
14+
},
15+
16+
getText(activeTextEditor) {
17+
return activeTextEditor.document.getText();
18+
},
19+
20+
getPath(activeTextEditor) {
21+
return activeTextEditor.document.fileName;
22+
},
23+
24+
save(activeTextEditor) {
25+
activeTextEditor.document.save();
26+
}
27+
}
28+
29+
module.exports = editor;

lib/extension.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const buildCommand = require('./static/buildCommand.js');
2+
const hostApps = require('./static/hostApps.js');
3+
const vscode = require('vscode');
4+
5+
/**
6+
* @description Method is called when extension is activated.
7+
* Extension is activated the very first time the command is executed.
8+
* @param {any} context vscode.ExtensionContext
9+
*/
10+
function activate(context) {
11+
hostApps.forEach(hostApp => {
12+
vscode.commands.registerCommand(
13+
`adobeScriptRunner.${hostApp.shortName}`,
14+
() => buildCommand(hostApp)
15+
);
16+
});
17+
}
18+
19+
exports.activate = activate;

lib/message.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const vscode = require('vscode');
2+
const message = {
3+
success (message) {
4+
vscode.window.showInformationMessage(message);
5+
},
6+
7+
info (message) {
8+
vscode.window.showWarningMessage(message);
9+
},
10+
11+
error (message) {
12+
vscode.window.showErrorMessage(string);
13+
}
14+
}
15+
16+
module.exports = message;

lib/static/buildCommand.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const cp = require('child_process');
2+
const getScriptFile = require('./getScriptFile.js');
3+
const getShellCommand = require('./getShellCommand.js');
4+
5+
const config = require('../config.js');
6+
const message = require('../message.js');
7+
8+
/**
9+
* @description Implementation of the activation command.
10+
* @param {any} hostApp Object, entry from hostApps[hostApp].
11+
* @returns {boolean} Nothing on success. 'null' on error.
12+
*/
13+
function buildCommand(hostApp) {
14+
try {
15+
const settings = config.update();
16+
const scriptFile = getScriptFile(settings);
17+
const command = getShellCommand(hostApp, scriptFile, settings);
18+
19+
console.log('Running shell command:', command);
20+
cp.exec(command, (err, result, raw) => {
21+
if (err) {
22+
return console.error(err);
23+
}
24+
console.log(result);
25+
console.log(raw);
26+
});
27+
28+
message.success(`Script sent to ${hostApp.appName}`);
29+
30+
} catch (err) {
31+
if (err) {
32+
message.error(err.toString());
33+
console.log(err);
34+
}
35+
}
36+
}
37+
38+
module.exports = buildCommand;

0 commit comments

Comments
 (0)