File tree Expand file tree Collapse file tree 4 files changed +54
-0
lines changed
Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 66
77 data FS :: !
88
9+ data SymlinkType where
10+ FileLink :: SymlinkType
11+ DirLink :: SymlinkType
12+ JunctionLink :: SymlinkType
13+
14+
15+ ### Type Class Instances
16+
17+ instance eqSymlinkType :: Eq SymlinkType
18+
19+ instance showSymlinkType :: Show SymlinkType
20+
921
1022## Module Node.FS.Async
1123
Original file line number Diff line number Diff line change @@ -4,3 +4,20 @@ module Node.FS where
44-- Effect type for file system usage.
55--
66foreign import data FS :: !
7+
8+ -- |
9+ -- Symlink varieties.
10+ --
11+ data SymlinkType = FileLink | DirLink | JunctionLink
12+
13+ instance showSymlinkType :: Show SymlinkType where
14+ show FileLink = " file"
15+ show DirLink = " dir"
16+ show JunctionLink = " junction"
17+
18+ instance eqSymlinkType :: Eq SymlinkType where
19+ (==) FileLink FileLink = true
20+ (==) DirLink DirLink = true
21+ (==) JunctionLink JunctionLink = true
22+ (==) _ _ = false
23+ (/=) x y = not (x == y)
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ foreign import fs "var fs = require('fs');" ::
4343 , chmod :: Fn3 FilePath Number (JSCallback Unit ) Unit
4444 , stat :: Fn2 FilePath (JSCallback StatsObj ) Unit
4545 , link :: Fn3 FilePath FilePath (JSCallback Unit ) Unit
46+ , symlink :: Fn4 FilePath FilePath String (JSCallback Unit ) Unit
4647 , readFile :: forall a opts . Fn3 FilePath { | opts } (JSCallback a ) Unit
4748 , writeFile :: forall a opts . Fn4 FilePath a { | opts } (JSCallback Unit ) Unit
4849 }
@@ -117,6 +118,18 @@ link :: forall eff. FilePath
117118
118119link src dst cb = return $ runFn3
119120 fs.link src dst (handleCallback cb)
121+
122+ -- |
123+ -- Creates a symlink.
124+ --
125+ symlink :: forall eff . FilePath
126+ -> FilePath
127+ -> SymlinkType
128+ -> Callback eff Unit
129+ -> Eff (fs :: FS | eff ) Unit
130+
131+ symlink src dest ty cb = return $ runFn4
132+ fs.symlink src dest (show ty) (handleCallback cb)
120133
121134-- |
122135-- Reads the entire contents of a file returning the result as a raw buffer.
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ foreign import fs "var fs = require('fs');" ::
2727 , chmodSync :: Fn2 FilePath Number Unit
2828 , statSync :: Fn1 FilePath StatsObj
2929 , linkSync :: Fn2 FilePath FilePath Unit
30+ , symlinkSync :: Fn3 FilePath FilePath String Unit
3031 , readFileSync :: forall a opts . Fn2 FilePath { | opts } a
3132 , writeFileSync :: forall a opts . Fn3 FilePath a { | opts } Unit
3233 }
@@ -96,6 +97,17 @@ link :: forall eff. FilePath
9697link src dst = mkEff $ \_ -> runFn2
9798 fs.linkSync src dst
9899
100+ -- |
101+ -- Creates a symlink.
102+ --
103+ symlink :: forall eff . FilePath
104+ -> FilePath
105+ -> SymlinkType
106+ -> Eff (fs :: FS , err :: Exception Error | eff ) Unit
107+
108+ symlink src dst ty = mkEff $ \_ -> runFn3
109+ fs.symlinkSync src dst (show ty)
110+
99111-- |
100112-- Reads the entire contents of a file returning the result as a raw buffer.
101113--
You can’t perform that action at this time.
0 commit comments