Skip to content

Commit

Permalink
Better tracing if we have IO error in load script generation
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Dec 21, 2017
1 parent 8e9c7e8 commit 8e88b66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 5.126.4 - 2017-12-21
* USABILITY: Better tracing if we have IO error in load script generation

#### 5.126.3 - 2017-12-18
* USABILITY: Do not download more than 5 packages at the same time

Expand Down
34 changes: 17 additions & 17 deletions src/Paket.Core/Installation/ScriptGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,28 @@ module ScriptGeneration =
self.Input |> Seq.map refString |> Seq.distinct |> String.concat "\n"

/// Save the script in '<directory>/.paket/load/<script>'
member self.Save (rootPath:DirectoryInfo) =
rootPath.Create()
member self.Save (rootPath:DirectoryInfo) =
if not rootPath.Exists then rootPath.Create()
let scriptFile = FileInfo (rootPath.FullName </> self.PartialPath)
if verbose then
verbosefn "generating script - %s" scriptFile.FullName
scriptFile.Directory.Create()
let text = self.Render rootPath
if not scriptFile.Directory.Exists then scriptFile.Directory.Create()

let existingFileContents =
if scriptFile.Exists then
Some (File.ReadAllText scriptFile.FullName)
if scriptFile.Exists then
try
File.ReadAllText scriptFile.FullName
with
| exn -> failwithf "Could not read load script file %s. Message: %s" scriptFile.FullName exn.Message
else
None

match existingFileContents with
| Some contents when contents = text ->
if verbose then
verbosefn "script contents hasn't changed - %s" scriptFile.FullName
| None | Some _ ->
File.WriteAllText (scriptFile.FullName, text)
""

let text = self.Render rootPath
try
if existingFileContents <> text then
File.WriteAllText (scriptFile.FullName, text)
with
| exn -> failwithf "Could not write load script file %s. Message: %s" scriptFile.FullName exn.Message

type PaketContext = {
Cache : DependencyCache
Expand All @@ -160,7 +161,7 @@ module ScriptGeneration =

/// Generate a include scripts for all packages defined in paket.dependencies,
/// if a package is ordered before its dependencies this function will throw.
let generateScriptContent (context:PaketContext as ctx) =
let generateScriptContent (ctx:PaketContext) =

let scriptType, groups, (isDefaultFramework, framework) = ctx.ScriptType, ctx.Groups, ctx.DefaultFramework

Expand Down Expand Up @@ -283,8 +284,7 @@ module ScriptGeneration =
|> Seq.filter (snd >> Option.isNone)
|> Seq.map fst
|> String.concat ", "
|> sprintf "%s: %s. Cannot generate include scripts." message
|> failwith
|> failwithf "%s: %s. Can't generate load scripts." message

// prepare list of frameworks to generate, paired with "is default framework"
// default framework will get generated under root folder rather than framework specific subfolder
Expand Down

0 comments on commit 8e88b66

Please sign in to comment.