MattCheely / requirejs-maven-plugin

Maven plugin for RequireJS optimization
GNU Lesser General Public License v2.1
66 stars 21 forks source link

Spaces in path names #19

Open dwward opened 11 years ago

dwward commented 11 years ago

Hi, I am using your plugin and it is not handling spaces with path names when running nodejs. I was using the filtered-build mechanism and I am unable to control the double quotes properly. This was causing me a problem in my CI environment which resides under "C:\Program Files...." I was able to work around this by pulling the plugin and making changes to executeScript(...) method. I used the expanded form of CommandLine.

Could something like this be included in a future release? I just joined GitHub about 10 minutes ago and I'm still learning how this all works.

NodeJsRunner.java

  private boolean executeScript(String nodeJsFile, String scriptName, String[] params) throws IOException {
    String optimizeFlag = params[0];
    String targetFile = params[1];

    Map<String, File> substitutionMap = new HashMap<String, File>();
    substitutionMap.put("scriptName",  new File(scriptName));
    substitutionMap.put("targetFile",  new File(targetFile));

    CommandLine cmdLine = new CommandLine(nodeJsFile);
    cmdLine.addArgument("${scriptName}");
    cmdLine.addArgument(optimizeFlag);
    cmdLine.addArgument("${targetFile}");
    cmdLine.setSubstitutionMap(substitutionMap);

    DefaultExecutor executor = new DefaultExecutor();
    try {
      return executor.execute(cmdLine) == 0;
    } catch (ExecuteException e) {
      return e.getExitValue() == 0;
    }
  }
MattCheely commented 11 years ago

Hello, and welcome to github! I have pushed a new version which I think should resolve your issue. You can build it from source, or you should be able to update your project's version of the plugin to 2.0.0-SNAPSHOT, in which case you will need to add the sonatype snapshot repository to your pom, by adding the tags below to the project config

<repositories>
    <repository>
      <id>sonatype-snapshot</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    </repository>
 </repositories>

If you can try it out and let me know if it works for you, I would greatly appreciate it.