aboutsummaryrefslogtreecommitdiffstats
path: root/FMark/src/Common/FableFileIO.fs
blob: 77c3d69229b7b4c0851ab51cba432444fe2d7bce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module FileIO

open Fable.Import.Node.Exports

let writeToFile str path =
    let errorHandler _err = () // Ignore all errors
    fs.writeFile(path, str, errorHandler)

let splitString (s:string) =
    s.Split("\n") |> Array.toList

let checkExists (path:string) =
    fs.existsSync(Fable.Core.U2.Case1 path)
let readFilePath path =
    path 
    |> checkExists
    |> function
    | true ->
        fs.readFileSync(path,()) 
        |> (fun s -> s.toString ())
        |> splitString
    | false -> []