0

I want to compile some JS files inside a folder using the closure compiler, the issue I am facing is that when I am trying to compile the files in a folder(which contains JS files) whose name has got a whitespace, the closure compiler breaks and cannot recognize the path. Eg If the folder name that I want to compile is D:\New Folder, it doesn't works but if the name is D:\NewFolder it works.

The exact command I am using to run the closure in command prompt is

C:\closure-compiler>java -jar compiler.jar D:\New Folder\\*.js --js_output_file D:\Output.js

But when I run the following command it works

C:\closure-compiler>java -jar compiler.jar D:\NewFolder\\*.js --js_output_file D:\Output.js

(Where closure-compiler is the directory which contains the closure compiler jar file). I am running Closure Compiler on Windows 7 Enterprise and invoking it from the command line.

Is there a way that I* can resolve it?

  • What command are you using to compile the files? – Tibos Nov 20 '13 at 11:50
  • (many) Other programs allow you to specify the path inside parenthesis. I.e `somProgram -someSwitch c:/some path/file.ext` would be a problem as is, and would be re-written as `somProgram -someSwitch 'c:/some path/file.ext'` – enhzflep Nov 20 '13 at 12:26
  • You haven't posted enough information for us to help. It depends on your operating system, whether the compiler is being invoked from the command line or via a build script, etc. – Chad Killingsworth Nov 20 '13 at 14:11
  • @Tibos I am using the following command to compile the files java -jar compiler.jar --js D:\New Folder*.js --js_output_file output.js – user3012728 Nov 22 '13 at 09:06
  • @ChadKillingsworth I am Windows 7 and it gives an error in both cases ie when invoked from command line as well as buildscript – user3012728 Nov 22 '13 at 09:09
  • Have you tried `--js="D:\New Folder*.js"` or even `--js "D:\New Folder*.js"`? – Tibos Nov 22 '13 at 09:10
  • @Tibos Yeah I have tried both but it doesn't works for me – user3012728 Nov 22 '13 at 09:14
  • @Chad Killingsworth Don't you think its too early to close this topic? The topic was started at Nov20 at 11:48 and was closed at Nov 20 21:44. I think I have replied to my best, against the questions that were put up. I wanted to seek help from the community because was stuck in something, the idea was not to post the question but to resolve it. – user3012728 Nov 27 '13 at 06:41
  • If you want to post the full details of how you are invoking the compiler, including OS, whether it is part of a build step or batch script and the full set of options you are using, I'll vote to reopen the question. – Chad Killingsworth Nov 27 '13 at 13:17
  • @Chad Killingsworth I have reframed the question, please can you reopen it now. Do let me know in case the informaton is still insufficient. – user3012728 Nov 28 '13 at 06:27
  • @Ryan Cavanaugh I have reframed the question, please can you reopen it now. Do let me know in case the informaton is still insufficient. – user3012728 Nov 28 '13 at 06:27

1 Answers1

0

You have more than one issue affecting you:

  1. Javascript input files must be specified using the --js flag
  2. Files must be explicitly specified - wildcards are not currently supported.
  3. Directory paths with with spaces must be quoted in Windows.

Here's a corrected version of your command that worked for me in a test environment:

java -jar compiler.jar --js "d:\New Folder\input.js"
    --js_output_file D:\Output.js
Chad Killingsworth
  • 14,360
  • 2
  • 34
  • 57
  • I tried the same command specified by you but still it gives an error that it cannot read the directory and once the "New Folder" is renamed to NewFolder it works. – user3012728 Dec 03 '13 at 09:26
  • You are executing this from standard windows command prompt, correct? – Chad Killingsworth Dec 03 '13 at 14:08
  • Then I would make sure you are using the latest version of the compiler, because I tested that exact command at the windows 7 command prompt and it worked as expected. Batch jobs, other shells (such as cygwin or git bash) may not work in the same way or have different escape characters. – Chad Killingsworth Dec 04 '13 at 15:34
  • Thanks for the reply @Chad Killingsworth. I am using following version & build number of Closure Compiler Version : v20131014 Built on : 2013/10/15 09:45 Do I need to use some other version to resolve this ? – user3012728 Dec 05 '13 at 04:28