Permalink
Browse files

Add "node" as a core module.

  • Loading branch information...
moll committed Sep 6, 2013
1 parent 214af10 commit 29486a87272a0a815f6c270b7888acf6e13d6081
Showing with 38 additions and 8 deletions.
  1. +3 −0 CHANGELOG.md
  2. +9 −4 Makefile
  3. +3 −2 autoload/node/lib.vim
  4. +22 −1 test/autoload/lib_test.rb
  5. +1 −1 test/helper.rb
View
@@ -1,3 +1,6 @@
+## Unreleased
+- Adds `node` as a core module so you could use `:Nedit node` to open the file Node uses to bootstrap its core.
+
## 0.7.0 (Aug 28, 2013)
- Adds support for opening core Node.js modules, such as `http`, `util`, etc. with `gf` or `:Nedit`.
They're shown straight from Node's online repository without you having to download everything.
View
@@ -22,10 +22,15 @@ publish:
tag:
git tag "v$(VERSION)"
-list-core-modules:
- wget "https://github.com/joyent/node/archive/master.tar.gz" -O- |\
- tar tf - |\
+node.tar.gz:
+ wget "https://github.com/joyent/node/archive/master.tar.gz" \
+ --output-document node.tar.gz \
+ --continue
+
+list-core-modules: node.tar.gz
+ tar tf node.tar.gz |\
egrep "^node[^/]*/lib/.+" |\
- xargs -n1 basename -s .js
+ xargs -n1 basename -s .js |\
+ { cat; echo node; } | sort
.PHONY: love test autotest pack publish tag
View
@@ -10,15 +10,16 @@ let s:CORE_MODULES = ["_debugger", "_http_agent", "_http_client",
\ "_stream_transform", "_stream_writable", "_tls_legacy", "_tls_wrap",
\ "assert", "buffer", "child_process", "cluster", "console", "constants",
\ "crypto", "dgram", "dns", "domain", "events", "freelist", "fs", "http",
- \ "https", "module", "net", "os", "path", "punycode", "querystring",
+ \ "https", "module", "net", "node", "os", "path", "punycode", "querystring",
\ "readline", "repl", "smalloc", "stream", "string_decoder", "sys",
\ "timers", "tls", "tty", "url", "util", "vm", "zlib"]
function! node#lib#find(name, from)
if index(s:CORE_MODULES, a:name) != -1
let l:version = node#lib#version()
let l:version = empty(l:version) ? "master" : "v" . l:version
- return s:CORE_URL_PREFIX ."/". l:version ."/lib/". a:name .".js"
+ let l:dir = a:name == "node" ? "src" : "lib"
+ return s:CORE_URL_PREFIX ."/". l:version ."/". l:dir ."/". a:name .".js"
endif
return s:resolve(s:absolutize(a:name, a:from))
View
@@ -247,14 +247,30 @@ def find(name)
find("assert").must_equal url
end
- it "must return URL for core module on master if no Node fails" do
+ it "must return URL for core module on master if no Node version" do
touch File.join(@dir, "node"), "#!/bin/sh\nexit 1"
File.chmod 0755, File.join(@dir, "node")
$vim.edit File.join(@dir, "index.js")
$vim.command(%(let $PATH = "#@dir:" . $PATH))
url = "http://rawgithub.com/joyent/node/master/lib/assert.js"
find("assert").must_equal url
end
+
+ it "must return URL for node.js for current Node version" do
+ set_node_version "0.13.37"
+ $vim.edit File.join(@dir, "index.js")
+ url = "http://rawgithub.com/joyent/node/v0.13.37/src/node.js"
+ find("node").must_equal url
+ end
+
+ it "must return URL for node.js on master if no Node version" do
+ touch File.join(@dir, "node"), "#!/bin/sh\nexit 1"
+ File.chmod 0755, File.join(@dir, "node")
+ $vim.edit File.join(@dir, "index.js")
+ $vim.command(%(let $PATH = "#@dir:" . $PATH))
+ url = "http://rawgithub.com/joyent/node/master/src/node.js"
+ find("node").must_equal url
+ end
end
describe "node#lib#glob" do
@@ -292,6 +308,11 @@ def glob(arg = "")
glob.wont_equal /\//
end
+ # Even though node.js is the bootstrapper file in src/.
+ it "must return \"node\" as one of those core modules" do
+ glob.must_include "node"
+ end
+
it "must return files, directories and modules" do
FileUtils.mkpath File.join(@dir, "node_modules", "export")
FileUtils.mkpath File.join(@dir, "node_modules", "soul")
View
@@ -44,5 +44,5 @@ def touch(path, contents = nil)
_stream_passthrough _stream_readable _stream_transform _stream_writable
_tls_legacy _tls_wrap assert buffer child_process cluster console
constants crypto dgram dns domain events freelist fs http https module
- net os path punycode querystring readline repl smalloc stream
+ net node os path punycode querystring readline repl smalloc stream
string_decoder sys timers tls tty url util vm zlib]

0 comments on commit 29486a8

Please sign in to comment.