diff options
author | eric thul <thul.eric@gmail.com> | 2015-07-06 23:49:47 -0400 |
---|---|---|
committer | eric thul <thul.eric@gmail.com> | 2015-07-06 23:55:06 -0400 |
commit | 0e1221d7b15e578d5e9146b01e11a24007d4ba9b (patch) | |
tree | aa70df70f6c36b7a85783c28d7eb256854b4232c /src/Glob.purs | |
parent | bc4de0853bd1cbf63842b3b66bb30494c9ea778a (diff) | |
download | purs-loader-0e1221d7b15e578d5e9146b01e11a24007d4ba9b.tar.gz purs-loader-0e1221d7b15e578d5e9146b01e11a24007d4ba9b.tar.zst purs-loader-0e1221d7b15e578d5e9146b01e11a24007d4ba9b.zip |
Generate .psci file
Resolves #11
Diffstat (limited to 'src/Glob.purs')
-rw-r--r-- | src/Glob.purs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Glob.purs b/src/Glob.purs new file mode 100644 index 0000000..392d9e4 --- /dev/null +++ b/src/Glob.purs | |||
@@ -0,0 +1,33 @@ | |||
1 | module PursLoader.Glob | ||
2 | ( Glob() | ||
3 | , globAll | ||
4 | ) where | ||
5 | |||
6 | import Control.Monad.Aff (Aff(), makeAff) | ||
7 | import Control.Monad.Eff (Eff()) | ||
8 | import Control.Monad.Eff.Exception (Error()) | ||
9 | |||
10 | import Data.Function | ||
11 | |||
12 | foreign import data Glob :: ! | ||
13 | |||
14 | globAll :: forall eff. [String] -> Aff (glob :: Glob | eff) [[String]] | ||
15 | globAll patterns = makeAff $ runFn3 globAllFn patterns | ||
16 | |||
17 | foreign import globAllFn """ | ||
18 | function globAllFn(patterns, errback, callback) { | ||
19 | return function(){ | ||
20 | var glob = require('glob'); | ||
21 | |||
22 | var async = require('async'); | ||
23 | |||
24 | async.map(patterns, glob, function(error, result){ | ||
25 | if (error) errback(new Error(error))(); | ||
26 | else callback(result)(); | ||
27 | }); | ||
28 | }; | ||
29 | } | ||
30 | """ :: forall eff. Fn3 [String] | ||
31 | (Error -> Eff (glob :: Glob | eff) Unit) | ||
32 | ([[String]] -> Eff (glob :: Glob | eff) Unit) | ||
33 | (Eff (glob :: Glob | eff) Unit) | ||