Browse files

fixed some bugs

  • Loading branch information...
1 parent 95e8756 commit b490cbf0a31701fb98277ede7a600c9f636e6e09 @sirrapa committed Dec 17, 2012
View
40 src/main/java/com/sirrapa/maven/plugins/nodejs/NodeJsMojo.java
@@ -43,7 +43,7 @@
/**
* The nodejs nodejsVersion
*/
- @Parameter( defaultValue = "0.8")
+ @Parameter(defaultValue = "0.8")
protected String nodejsVersion;
/**
* The nodejs nodejsType
@@ -78,11 +78,11 @@
public static final String SOLARIS_FAMILY = "sunos";
public static final String MAC_FAMILY = "mac";
- public static final String[][] OS_CLASSIFIER_FAMILIES = new String[][] {
- {WINDOWS_FAMILY,CLASSIFIER_WINDOWS_FAMILY},
- { LINUX_FAMILY,CLASSIFIER_LINUX_FAMILY},
- { SOLARIS_FAMILY,CLASSIFIER_UNIX_FAMILY},
- { MAC_FAMILY,CLASSIFIER_MAC_FAMILY }};
+ public static final String[][] OS_CLASSIFIER_FAMILIES = new String[][]{
+ {WINDOWS_FAMILY, CLASSIFIER_WINDOWS_FAMILY},
+ {LINUX_FAMILY, CLASSIFIER_LINUX_FAMILY},
+ {SOLARIS_FAMILY, CLASSIFIER_UNIX_FAMILY},
+ {MAC_FAMILY, CLASSIFIER_MAC_FAMILY}};
/**
@@ -120,15 +120,16 @@ protected int executeCommandLine(Commandline commandLine, StreamConsumer stream1
/**
* Determine the right command executable for the given osFamily
+ *
* @param osFamily
* @return
*/
protected String getNodeJsExecutable(String osFamily) {
System.out.println("Determing executable for osFamily = " + osFamily);
StringBuilder sb = new StringBuilder(nodejsDirectory.getAbsolutePath());
- if(osFamily.toLowerCase().startsWith(CLASSIFIER_WINDOWS_FAMILY)) {
+ if (osFamily.toLowerCase().startsWith(CLASSIFIER_WINDOWS_FAMILY)) {
sb.append(File.separator).append("node.exe");
- }else {
+ } else {
sb.append(File.separator).append("bin").append(File.separator).append("node");
}
System.out.println("Determined executable for osFamily: " + sb.toString());
@@ -139,8 +140,8 @@ protected void executeNodeJs() throws MojoExecutionException, CommandLineExcepti
// create a commandline and set the executable to nodejs
Commandline commandLine = new Commandline();
- if(! workingDirectory.exists()) {
- workingDirectory.mkdirs();
+ if (!workingDirectory.exists()) {
+ workingDirectory.mkdirs();
}
commandLine.setWorkingDirectory(workingDirectory);
@@ -150,10 +151,9 @@ public void consumeLine(String line) {
}
};
- commandLine.clearArgs();
- String executable = getNodeJsExecutable(nodejsClassifier)+" %s";
+ String executable = getNodeJsExecutable(nodejsClassifier) + " %s";
for (String module : modules) {
- commandLine.setExecutable(String.format(executable,module));
+ commandLine.setExecutable(String.format(executable, module));
System.out.println("commandLine = " + commandLine);
int result = executeCommandLine(commandLine, consumer, consumer);
@@ -210,24 +210,20 @@ protected void initializeModulesConfiguration()
/**
* @return the operating system name
*/
- private static String getOsName()
- {
- return System.getProperty( "os.name" ).toLowerCase();
+ private static String getOsName() {
+ return System.getProperty("os.name").toLowerCase();
}
/**
* Get the OS classifier family, this looks in the OS_FAMILIES array for a match
*
* @return the os family
*/
- public static String getOSClassifier()
- {
+ public static String getOSClassifier() {
String osName = getOsName();
String classifier = null;
- for ( int i = 0; i < OS_CLASSIFIER_FAMILIES.length; ++i )
- {
- if ( osName.startsWith( OS_CLASSIFIER_FAMILIES[i][0] ) )
- {
+ for (int i = 0; i < OS_CLASSIFIER_FAMILIES.length; ++i) {
+ if (osName.startsWith(OS_CLASSIFIER_FAMILIES[i][0])) {
classifier = OS_CLASSIFIER_FAMILIES[i][1];
break;
}
View
1 src/test/java/com/sirrapa/maven/plugins/nodejs/NodeJsMojoTest.java
@@ -175,6 +175,7 @@ public void testGetNodeJsExecutable() throws Exception {
}
}
+
// public void testExecuteNodeJs() throws Exception {
// loadMojo("plugin-config.xml");
// mojo.initializeModulesConfiguration();

0 comments on commit b490cbf

Please sign in to comment.