diff options
author | anekos | 2010-07-31 13:17:19 +0000 |
---|---|---|
committer | anekos | 2010-07-31 13:17:19 +0000 |
commit | 6a46d7111c328f9a4bb3489b32698902fa813e88 (patch) | |
tree | 7d1092d5ec87dbb3c1f8b679cf5d4648462ff498 /twittperator.js | |
parent | ceb55ae4d17e78a07ca6ec74096171c4adf0d0a1 (diff) | |
download | vimperator-plugins-6a46d7111c328f9a4bb3489b32698902fa813e88.tar.bz2 |
プラグインのロードをちょっとだけ安全に
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38102 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'twittperator.js')
-rwxr-xr-x | twittperator.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/twittperator.js b/twittperator.js index 58ac1e0..20dfe81 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1349,11 +1349,20 @@ } // }}} function sourceScriptFile(file) { // {{{ // XXX 悪い子向けのハックです。すみません。 *.tw ファイルを *.js のように読み込みます。 - file = file.clone; + function getScriptName(file) + file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase()); + + file = file.clone(); let toString = file.toString; + let scriptName = getScriptName(file); + let script = liberator.plugins[scriptName]; file.toString = function () this.path.replace(/\.tw$/, ".js"); - io.source(file, false); - file.toString = toString; + try { + io.source(file, false); + } finally { + liberator.plugins[scriptName] = script; + file.toString = toString; + } } // }}} function loadPlugins() { // {{{ io.getRuntimeDirectories("plugin/twittperator").forEach(function(dir) { @@ -1477,9 +1486,6 @@ function loadPlugins() { // {{{ } } }, true); - - if (setting.useChirp) - ChirpUserStream.start(); } // }}} // PIN code を取得して AccessToken を得る前 {{{ function preSetup() { @@ -1533,6 +1539,11 @@ function loadPlugins() { // {{{ __context__.OAuth = tw; __context__.ChirpUserStream = ChirpUserStream; + + loadPlugins(); + + if (setting.useChirp) + ChirpUserStream.start(); // }}} })(); |