-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- F ReporterThatCreatesAnApprovalScript for Windows
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ltests/src/main/java/org/approvaltests/reporters/ReporterThatCreatesAnApprovalScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.approvaltests.reporters; | ||
|
||
import com.spun.util.SystemUtils; | ||
import com.spun.util.io.FileUtils; | ||
import com.spun.util.logger.SimpleLogger; | ||
import org.approvaltests.ApprovedFileLog; | ||
import org.approvaltests.core.ApprovalFailureReporter; | ||
|
||
import java.io.File; | ||
|
||
public class ReporterThatCreatesAnApprovalScript implements ApprovalFailureReporter { | ||
private static String fileName = "approval_script"; | ||
private static File scriptFile = null; | ||
static { | ||
initializeFile(); | ||
|
||
} | ||
|
||
private static void initializeFile() { | ||
if (scriptFile != null) {return;} | ||
if (SystemUtils.isWindowsEnvironment()) { | ||
initializeWindows(); | ||
} else { | ||
initializeLinux(); | ||
} | ||
SimpleLogger.event("Created approval script:\n" + scriptFile.getAbsolutePath()); | ||
} | ||
|
||
private static void initializeLinux() { | ||
|
||
} | ||
|
||
private static void initializeWindows() { | ||
scriptFile = new File(ApprovedFileLog.APPROVAL_TEMP_DIRECTORY + "\\" + fileName + ".bat"); | ||
FileUtils.createIfNeeded(scriptFile.getAbsolutePath()); | ||
FileUtils.writeFile(scriptFile, ""); | ||
} | ||
|
||
@Override | ||
public boolean report(String received, String approved) { | ||
String commandLine = ClipboardReporter.getCommandLine(received, approved); | ||
FileUtils.appendToFile(scriptFile, commandLine + "\r\n"); | ||
return true; | ||
} | ||
} |