-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from NajSurf/master
Fix for generatedFiles
- Loading branch information
Showing
6 changed files
with
340 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,112 @@ | ||
// 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') | ||
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(); | ||
|
||
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(); | ||
|
||
if(!syncHelper) | ||
syncHelper = require('./modules/sync-helper')(); | ||
else if(ftpConfig.connectionChanged(oldConfig)) | ||
syncHelper.disconnect(); | ||
syncHelper.useConfig(currentConfig); | ||
|
||
syncHelper.useConfig(currentConfig) | ||
return syncHelper; | ||
}; | ||
|
||
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 downloadcurrentCommand = vscode.commands.registerCommand( | ||
"extension.ftpsyncdownloadselected", | ||
function(fileUrl) { | ||
require("./modules/downloadcurrent-command")(fileUrl, getSyncHelper); | ||
} | ||
); | ||
var listcurrentCommand = vscode.commands.registerCommand( | ||
"extension.ftpsynclistselected", | ||
function(fileUrl) { | ||
require("./modules/list-command")(fileUrl, getSyncHelper); | ||
} | ||
); | ||
var onSave = require("./modules/on-save"); | ||
var onGenerate = require("./modules/on-generate"); | ||
|
||
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 downloadcurrentCommand = vscode.commands.registerCommand("extension.ftpsyncdownloadselected", function(fileUrl) { require('./modules/downloadcurrent-command')(fileUrl, getSyncHelper) }); | ||
var listcurrentCommand = vscode.commands.registerCommand("extension.ftpsynclistselected", function(fileUrl) { require('./modules/list-command')(fileUrl, getSyncHelper) }); | ||
var onSave = require('./modules/on-save'); | ||
var currentConfig = getSyncHelper().getConfig(); | ||
if (currentConfig.generatedFiles.uploadOnSave) { | ||
fsw = vscode.workspace.createFileSystemWatcher( | ||
currentConfig.getGeneratedDir() + "/**" | ||
); | ||
// fsw.onDidChange(function(ev) { | ||
// //an attempt to normalize onDidChange with onDidSaveTextDocument. | ||
// ev['uri'] = {fsPath: ev.fsPath}; | ||
// onSave(ev, getSyncHelper); | ||
// }) | ||
fsw.onDidCreate(function(ev) { | ||
ev["uri"] = { fsPath: ev.fsPath }; | ||
onGenerate(ev, getSyncHelper); | ||
}); | ||
fsw.onDidDelete(function(ev) { | ||
ev["uri"] = { fsPath: ev.fsPath }; | ||
onGenerate(ev, getSyncHelper); | ||
}); | ||
} | ||
|
||
var currentConfig = getSyncHelper().getConfig(); | ||
if (currentConfig.generatedFiles.uploadOnSave) { | ||
fsw = vscode.workspace.createFileSystemWatcher( currentConfig.getGeneratedDir() + '/**'); | ||
fsw.onDidChange(function(ev) { | ||
//an attempt to normalize onDidChange with onDidSaveTextDocument. | ||
ev['uri'] = {fsPath: ev.fsPath}; | ||
onSave(ev, getSyncHelper); | ||
}) | ||
fsw.onDidCreate(function(ev) { | ||
ev['uri'] = {fsPath: ev.fsPath}; | ||
onSave(ev, getSyncHelper); | ||
}) | ||
fsw.onDidDelete(function(ev) { | ||
ev['uri'] = {fsPath: ev.fsPath}; | ||
onSave(ev, getSyncHelper); | ||
}) | ||
} | ||
|
||
vscode.workspace.onDidSaveTextDocument( function(file) { | ||
onSave(file, getSyncHelper); | ||
}); | ||
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); | ||
context.subscriptions.push(downloadcurrentCommand); | ||
context.subscriptions.push(listcurrentCommand); | ||
context.subscriptions.push(initCommand); | ||
context.subscriptions.push(syncCommand); | ||
context.subscriptions.push(downloadCommand); | ||
context.subscriptions.push(commitCommand); | ||
context.subscriptions.push(singleCommand); | ||
context.subscriptions.push(uploadcurrentCommand); | ||
context.subscriptions.push(downloadcurrentCommand); | ||
context.subscriptions.push(listcurrentCommand); | ||
} | ||
|
||
exports.activate = activate; | ||
|
||
function deactivate() { | ||
fsw.dispose(); | ||
fsw.dispose(); | ||
} | ||
exports.deactivate = deactivate; |
Oops, something went wrong.