Skip to content

Commit

Permalink
Another common main file location
Browse files Browse the repository at this point in the history
  • Loading branch information
joeytwiddle committed Aug 12, 2016
1 parent f62e3b1 commit 2b5b60c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .vim/ftplugin/javascript.vim
Expand Up @@ -170,12 +170,17 @@ function! s:LoadNodeModule()
if !filereadable(fname)
let fname = s:SeekFile(['./node_modules/' . cfile . '/'], ['', '.js'], 'index.js')
endif
" But <package>/lib/index.js is quite a common location
" But <package>/main.js is quite a common location
if !filereadable(fname)
let fname = s:SeekFile(['./node_modules/' . cfile . '/'], ['', '.js'], 'main.js')
endif
" And <package>/lib/index.js is quite a common location
if !filereadable(fname)
let fname = s:SeekFile(['./node_modules/' . cfile . '/lib'], ['', '.js'], 'index.js')
endif
" TODO: In fact the entry point file location is configurable in
" package.json, so really we should read that!
" We could assume node is available, and do: node --eval 'fs=require("fs");data=JSON.parse(fs.readFileSync("./package.json"));console.log(data.bin)'
endif
if filereadable(fname)
let fname = simplify(fname)
Expand Down

0 comments on commit 2b5b60c

Please sign in to comment.