Merge pull request #2615 from ekrich/1.0.x

Add Windows script support and native file extensions on Unix platforms
This commit is contained in:
eugene yokota 2016-05-13 17:36:08 -04:00
commit 1d0eda2e6a
2 changed files with 21 additions and 2 deletions

View File

@ -20,10 +20,20 @@ object Script {
lazy val command =
Command.command(Name) { state =>
val scriptArg = state.remainingCommands.headOption getOrElse sys.error("No script file specified")
val script = new File(scriptArg).getAbsoluteFile
val hash = Hash.halve(Hash.toHex(Hash(script.getAbsolutePath)))
val scriptFile = new File(scriptArg).getAbsoluteFile
val hash = Hash.halve(Hash.toHex(Hash(scriptFile.getAbsolutePath)))
val base = new File(CommandUtil.bootDirectory(state), hash)
IO.createDirectory(base)
val src = new File(base, "src_managed")
IO.createDirectory(src)
// handle any script extension or none
val scalaFile = {
val dotIndex = scriptArg.lastIndexOf(".")
if (dotIndex == -1) scriptArg + ".scala"
else scriptArg.substring(0, dotIndex) + ".scala"
}
val script = new File(src, scalaFile)
IO.copyFile(scriptFile, script)
val (eval, structure) = Load.defaultLoad(state, base, state.log)
val session = Load.initialSession(structure, eval)

View File

@ -0,0 +1,9 @@
[@ekrich]: https://github.com/ekrich
### Fixes with compatibility implications
### Improvements
- Add Windows script support and native file extensions on Unix platforms. By [@ekrich][@ekrich]
### Bug fixes