aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-02-27 20:15:10 -0500
committereric thul <thul.eric@gmail.com>2016-02-27 20:15:10 -0500
commit3afbe2fddcc38ba6d79b01409f57158a217c00dd (patch)
tree7fbfb8f3bf11a3f3b5fbff95e58acdb8a6724627
parent861ae3407e82b2ef0fd08f6d4ff7f2b0df0b3ed7 (diff)
downloadpurs-loader-3afbe2fddcc38ba6d79b01409f57158a217c00dd.tar.gz
purs-loader-3afbe2fddcc38ba6d79b01409f57158a217c00dd.tar.zst
purs-loader-3afbe2fddcc38ba6d79b01409f57158a217c00dd.zip
Adding debug logging
-rw-r--r--docs/PursLoader/Debug.md9
-rw-r--r--package.json1
-rw-r--r--src/PursLoader/Debug.js12
-rw-r--r--src/PursLoader/Debug.purs9
-rw-r--r--src/PursLoader/Loader.purs6
5 files changed, 37 insertions, 0 deletions
diff --git a/docs/PursLoader/Debug.md b/docs/PursLoader/Debug.md
new file mode 100644
index 0000000..824a9f8
--- /dev/null
+++ b/docs/PursLoader/Debug.md
@@ -0,0 +1,9 @@
1## Module PursLoader.Debug
2
3#### `debug`
4
5``` purescript
6debug :: forall eff. String -> Eff (loader :: Loader | eff) Unit
7```
8
9
diff --git a/package.json b/package.json
index 4d1dff2..e1a79d6 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
26 "dependencies": { 26 "dependencies": {
27 "async": "^1.3.0", 27 "async": "^1.3.0",
28 "chalk": "^1.1.0", 28 "chalk": "^1.1.0",
29 "debug": "^2.2.0",
29 "loader-utils": "^0.2.6" 30 "loader-utils": "^0.2.6"
30 } 31 }
31} 32}
diff --git a/src/PursLoader/Debug.js b/src/PursLoader/Debug.js
new file mode 100644
index 0000000..85eca10
--- /dev/null
+++ b/src/PursLoader/Debug.js
@@ -0,0 +1,12 @@
1'use strict';
2
3// module PursLoader.Debug
4
5var debug_ = require('debug')('purs-loader');
6
7function debug(message) {
8 return function(){
9 debug_(message);
10 };
11}
12exports.debug = debug;
diff --git a/src/PursLoader/Debug.purs b/src/PursLoader/Debug.purs
new file mode 100644
index 0000000..7a02f69
--- /dev/null
+++ b/src/PursLoader/Debug.purs
@@ -0,0 +1,9 @@
1module PursLoader.Debug (debug) where
2
3import Prelude (Unit())
4
5import Control.Monad.Eff (Eff())
6
7import PursLoader.LoaderRef (Loader())
8
9foreign import debug :: forall eff. String -> Eff (loader :: Loader | eff) Unit
diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs
index f78153f..5e00f7e 100644
--- a/src/PursLoader/Loader.purs
+++ b/src/PursLoader/Loader.purs
@@ -34,6 +34,7 @@ import PursLoader.LoaderRef
34 , resourcePath 34 , resourcePath
35 ) 35 )
36 36
37import PursLoader.Debug (debug)
37import PursLoader.LoaderUtil (parseQuery) 38import PursLoader.LoaderUtil (parseQuery)
38import PursLoader.Options (Options(..)) 39import PursLoader.Options (Options(..))
39import PursLoader.Path (dirname, relative) 40import PursLoader.Path (dirname, relative)
@@ -47,6 +48,8 @@ loader ref source = do
47 48
48 cacheable ref 49 cacheable ref
49 50
51 debug "Invoke PureScript plugin compilation"
52
50 pluginContext.compile (compile callback) 53 pluginContext.compile (compile callback)
51 where 54 where
52 pluginContext :: Plugin.Context (Effects eff) 55 pluginContext :: Plugin.Context (Effects eff)
@@ -56,6 +59,8 @@ loader ref source = do
56 compile callback error' { srcMap, ffiMap, graph } = do 59 compile callback error' { srcMap, ffiMap, graph } = do
57 clearDependencies ref 60 clearDependencies ref
58 61
62 either (const $ pure unit) (\a -> debug ("Adding PureScript dependency " ++ a)) name
63
59 addDependency ref (resourcePath ref) 64 addDependency ref (resourcePath ref)
60 65
61 either (\err -> callback (Just err) "") id 66 either (\err -> callback (Just err) "") id
@@ -63,6 +68,7 @@ loader ref source = do
63 where 68 where
64 handle :: String -> Array String -> String -> Eff (Effects eff) Unit 69 handle :: String -> Array String -> String -> Eff (Effects eff) Unit
65 handle name' deps res = do 70 handle name' deps res = do
71 debug ("Adding PureScript transitive dependencies for " ++ name')
66 addTransitive name' 72 addTransitive name'
67 foreachE deps addTransitive 73 foreachE deps addTransitive
68 callback (toMaybe error') res 74 callback (toMaybe error') res