forked from lukasz-wronski/vscode-ftp-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
48 lines (37 loc) · 2.11 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
var vscode = require('vscode');
global.STATUS_TIMEOUT = 3000;
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
var syncHelper, currentConfig;
var ftpConfig = require('./modules/ftp-config');
var getSyncHelper = function() {
var oldConfig = currentConfig;
currentConfig = ftpConfig.getSyncConfig();
if(!syncHelper)
syncHelper = require('./modules/sync-helper')();
else if(ftpConfig.connectionChanged(oldConfig))
syncHelper.disconnect();
syncHelper.useConfig(currentConfig)
return syncHelper;
}
var initCommand = vscode.commands.registerCommand('extension.ftpsyncinit', require('./modules/init-command'));
var syncCommand = vscode.commands.registerCommand('extension.ftpsyncupload', function() { require('./modules/sync-command')(true, getSyncHelper) });
var downloadCommand = vscode.commands.registerCommand('extension.ftpsyncdownload', function() { require('./modules/sync-command')(false, getSyncHelper) });
var commitCommand = vscode.commands.registerCommand('extension.ftpsynccommit', function() { require('./modules/commit-command')(getSyncHelper) });
var singleCommand = vscode.commands.registerTextEditorCommand('extension.ftpsyncsingle', function(editor) { require('./modules/sync-single-command')(editor, getSyncHelper) });
var uploadcurrentCommand = vscode.commands.registerCommand("extension.ftpsyncuploadselected", function(fileUrl) { require('./modules/uploadcurrent-command')(fileUrl, getSyncHelper) });
var onSave = require('./modules/on-save');
vscode.workspace.onDidSaveTextDocument(function(file) {
onSave(file, getSyncHelper);
});
context.subscriptions.push(initCommand);
context.subscriptions.push(syncCommand);
context.subscriptions.push(downloadCommand);
context.subscriptions.push(commitCommand);
context.subscriptions.push(singleCommand);
context.subscriptions.push(uploadcurrentCommand);
}
exports.activate = activate;