Search code examples
javascriptrubycommand-lineargv

Does JavaScript have a way of passing in arguments through the terminal line like ARGV in Ruby?


I wrote a simple script in Ruby that accepts a file path as an argument from the terminal and then performs a task with that file.

EX:

files = ARGV

html = ""

file = File.open(files[0])

file.each do |line|
    html << line
end

code = html.gsub(/\s+/, "")
string = code.gsub(/"/, "'")

puts string

and from the terminal I can type ruby file.rb ~/path/to/file (the path is the argument being passed.)

Does JS have an argument vector like this?


Solution

  • No. JavaScript itself does not support this.