From ae0201407c2b741d5b15c2d994ed3ffd8b928676 Mon Sep 17 00:00:00 2001 From: secondlife Date: Tue, 24 Feb 2009 11:13:04 +0000 Subject: add force options git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@30494 d0d07461-0603-4401-acd4-de1884942a52 --- auto_source.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'auto_source.js') diff --git a/auto_source.js b/auto_source.js index f8c83ff..1578780 100644 --- a/auto_source.js +++ b/auto_source.js @@ -26,7 +26,7 @@ var PLUGIN_INFO = - :aso taro.js - :autoso[urce] taro.js - :autoso[urce] -c[ommand] 'colorscheme mycolors' taro.js - - :autoso[urce] -c[ommand] 'js alert("reload!")' taro.js + - :autoso[urce] -c[ommand] -force 'js alert("reload!")' taro.js 監視を中止: - :aso! taro.js - :autoso[urce]! taro.js @@ -64,9 +64,14 @@ var PLUGIN_INFO = return cur.path; } - function startWatching (filepath, command) { - if (exists(filepath)) - throw 'The file has already been watched: ' + filepath; + function startWatching (filepath, command, force) { + if (exists(filepath)) { + if (force) { + killWatcher(filepath); + } else { + throw 'The file has already been watched: ' + filepath; + } + } let last = firstTime ? null : getFileModifiedTime(filepath); let handle = setInterval(function () { try { @@ -100,13 +105,14 @@ var PLUGIN_INFO = ['autoso[urce]', 'aso'], 'Sourcing automatically when the specified file is modified.', function (arg, bang) { - (bang ? killWatcher : startWatching)(expandPath(arg[0]), arg['-command']); + (bang ? killWatcher : startWatching)(expandPath(arg[0]), arg['-command'], arg['-force']); }, { bang: true, argCount: '1', options: [ - [['-command', '-c'], commands.OPTION_STRING] + [['-command', '-c'], commands.OPTION_STRING], + [['-force', '-f'], commands.OPTION_NOARG] ], completer: function (context, args) { if (args.bang) { -- cgit v1.2.3