maksimr / vim-jsbeautify

vim plugin which formated javascript files by js-beautify
758 stars 68 forks source link

"Must define at least one file" error #80

Open onemanstartup opened 9 years ago

onemanstartup commented 9 years ago

Hi countryman, congrats on the holiday. I'm getting this error, tried different settings, doesn't helped.

Must define at least one file.
Run `beautify.min.js -h` for help.
maksimr commented 9 years ago

Hi,

Thanks, congrats you to.

What OS you use? What engine(node,v8,iojs) you use? What configurations you tried?

onemanstartup commented 9 years ago

I tried to install different versions of beautifiers, (tried changing editorconfig, but it seems it is not relevant) I'm using Mac OS X Yosemite, node version is v0.10.33, tried in console vim and MacVim

maksimr commented 9 years ago

@onemanstartup can print how look this line when you run command. Also will be cool if you run resulted line in terminal.

onemanstartup commented 9 years ago

Uh. How do i run this? I don't familiar with vimscript. It will take time to figure out this.

maksimr commented 9 years ago

You can change this line on

echo engine." ".fnameescape(s:plugin_Root_directory."/beautify.min.js")." --js_arguments ".tmp_file_Beautifier_arg." ".opts_Beautifier_arg." ".path_Beautifier_arg)
return 1
onemanstartup commented 9 years ago

Ok. Run through call ErrorMsg()

node /Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js --js_arguments "/var/folders/hm/ng5h
j9t949s6ljmgzwng_7hh0000gp/T/vlj6gW0/0" "{\"indent_char\": \" \", \"path\": \"~/.nvim/bundle/vim-jsbeautify/plugin/lib/js/bin/j
s-beautify.js\", \"max_line_length\": \"79\", \"indent_style\": \"space\", \"indent_size\": \"2\", \"wrap-line-length\": \"79\"
, \"max_char\": \"79\"}" "/Users/onemanstartup/.nvim/bundle/vim-jsbeautify/plugin/lib/js/bin/js-beautify.js"'
maksimr commented 9 years ago

@onemanstartup Thanks! Now try run this command in terminal

onemanstartup commented 9 years ago

It tells the same thing. I cat tmp file and it is containing content of the file. Also i ran js-beautify /var/folders/hm/ng5hj9t949s6ljmgzwng_7hh0000gp/T/vlj6gW0/0.js and it returned content.

maksimr commented 9 years ago

Hm.. try simple run node /Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js

onemanstartup commented 9 years ago

Here the error

fs.js:438
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
TypeError: path must be a string
    at Object.fs.openSync (fs.js:438:18)
    at Object.fs.readFileSync (fs.js:289:15)
    at read (/Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1462)
    at /Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1581
    at Object.<anonymous> (/Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1982)
    at Object.<anonymous> (/Users/onemanstartup/Code/d
maksimr commented 9 years ago

Cool! now let's pass one parameter

node /Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js --js_arguments "/var/folders/hm/ng5h
j9t949s6ljmgzwng_7hh0000gp/T/vlj6gW0/0"
onemanstartup commented 9 years ago

Here there error


/Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js:1
s=require("fs");load=function(path){var context={},property;if(path.charAt(0)!
                                                                    ^
TypeError: Cannot call method 'charAt' of undefined
    at load (/Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1194)
    at /Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1644
    at Object.<anonymous> (/Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1982)
    at Object.<anonymous> (/Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js:1:2011)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
maksimr commented 9 years ago

Good! Now with empty json

node /Users/onemanstartup/Code/dotfiles/vim2/bundle/vim-jsbeautify/plugin/beautify.min.js --js_arguments "/var/folders/hm/ng5h
j9t949s6ljmgzwng_7hh0000gp/T/vlj6gW0/0" "{}" "/Users/onemanstartup/.nvim/bundle/vim-jsbeautify/plugin/lib/js/bin/js-beautify.js"
onemanstartup commented 9 years ago

It's the same Must define at least one file