diff options
author | anekos | 2008-12-13 09:19:19 +0000 |
---|---|---|
committer | anekos | 2008-12-13 09:19:19 +0000 |
commit | 8542a995879e1f05b9921f88563bdf4cc52a741d (patch) | |
tree | 655dfb25ec18a43444b29248cda921ad23fbc9f9 /auto_source.js | |
parent | 72379dd288e862fa724b06e901d8dbe01a2fb2dc (diff) | |
download | vimperator-plugins-8542a995879e1f05b9921f88563bdf4cc52a741d.tar.bz2 |
カレントディレクトリを考慮するようにした。
(expandPath にパッチするべき?)
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26629 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'auto_source.js')
-rw-r--r-- | auto_source.js | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/auto_source.js b/auto_source.js index 2357cb9..1b7284d 100644 --- a/auto_source.js +++ b/auto_source.js @@ -3,7 +3,7 @@ var PLUGIN_INFO = <name> Auto Source </name> <description>Sourcing automatically when the specified file is modified.</description> <description lang="ja">指定のファイルが変更されたら自動で :so する。</description> - <version>1.2</version> + <version>1.3</version> <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> <minVersion>2.0pre</minVersion> <maxVersion>2.0pre</maxVersion> @@ -52,16 +52,30 @@ var PLUGIN_INFO = function remove (filepath, func) (files = files.filter(function (it) (it.path.indexOf(filepath) !== 0 && (func(it)+'-')))); + function expandPath (filepath) { + filepath = io.expandPath(filepath); + if (filepath.match(/\/|\w:[\\\/]/)) + return filepath; + let cur = io.getCurrentDirectory(); + cur.appendRelativePath(filepath); + return cur.path; + } + function startWatching (filepath) { if (exists(filepath)) throw 'The file has already been watched: ' + filepath; let last = firstTime ? null : getFileModifiedTime(filepath); let handle = setInterval(function () { - let current = getFileModifiedTime(filepath); - if (last != current) { - liberator.log('sourcing: ' + filepath); - last = current; - io.source(filepath); + try { + let current = getFileModifiedTime(filepath); + if (last != current) { + liberator.log('sourcing: ' + filepath); + last = current; + io.source(filepath); + } + } catch (e) { + killWatcher(filepath); + liberator.echoerr('Error! ' + filepath); } }, interval); files.push({handle: handle, path: filepath}); @@ -78,7 +92,7 @@ var PLUGIN_INFO = ['autoso[urce]', 'aso'], 'Sourcing automatically when the specified file is modified.', function (arg, bang) { - (bang ? killWatcher : startWatching)(io.expandPath(arg[0])); + (bang ? killWatcher : startWatching)(expandPath(arg[0])); }, { bang: true, |