Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 372a522

Browse files
committed
Update implementation for PureScript 0.7
1 parent fc001dd commit 372a522

30 files changed

+342
-234
lines changed

bower.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22
"name": "gulp-purescript",
33
"private": true,
44
"devDependencies": {
5-
"purescript-foreign": "0.4.2",
6-
"purescript-maybe": "0.2.2",
7-
"purescript-either": "0.1.8",
8-
"purescript-aff": "0.10.1",
9-
"purescript-exceptions": "0.2.3",
10-
"purescript-arrays": "0.3.7",
11-
"purescript-transformers": "0.5.5",
12-
"purescript-monad-eff": "0.1.0",
13-
"purescript-tuples": "0.3.4",
14-
"purescript-control": "0.2.6"
5+
"purescript-aff": "~0.11.3",
6+
"purescript-foreign": "~0.6.0"
157
}
168
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"scripts": {
1818
"test:run": "node test.js | tap-spec",
1919
"test": "npm run-script build && npm run-script test:run",
20-
"build:bootstrap": "npm install [email protected]",
21-
"build": "npm run-script build:bootstrap && npm run-script build:compile && npm run-script build:package",
22-
"build:compile": "gulp build",
20+
"build": "npm run-script build:compile && npm run-script build:docs && npm run-script build:package",
21+
"build:compile": "./node_modules/.bin/pulp build",
22+
"build:docs": "./node_modules/.bin/pulp docs",
2323
"build:package": "./node_modules/.bin/webpack --progress --colors --profile --bail",
2424
"build:json": "./node_modules/.bin/webpack --progress --colors --profile --bail --json > index.json",
2525
"prepublish": "npm run-script build"
@@ -44,6 +44,7 @@
4444
"gulp": "^3.8.11",
4545
"gulp-plumber": "^1.0.0",
4646
"json-loader": "^0.5.1",
47+
"pulp": "^4.3.0",
4748
"rewire": "^2.3.1",
4849
"run-sequence": "^1.0.2",
4950
"tap-spec": "^2.2.2",

src/Buffer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
// module GulpPurescript.Buffer
4+
5+
function mkBufferFromString(str) {
6+
return new Buffer(str);
7+
}
8+
9+
exports.mkBufferFromString = mkBufferFromString;

src/Buffer.purs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@ module GulpPurescript.Buffer
55

66
data Buffer
77

8-
foreign import mkBufferFromString """
9-
function mkBufferFromString(str) {
10-
return new Buffer(str);
11-
}
12-
""" :: String -> Buffer
8+
foreign import mkBufferFromString :: String -> Buffer

src/ChildProcess.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
// module GulpPurescript.ChildProcess
4+
5+
var child_process = require('cross-spawn');
6+
7+
function spawnFn(command, args, errback, callback) {
8+
return function(){
9+
var process = child_process.spawn(command, args);
10+
11+
var stdout = new Buffer(0);
12+
13+
var stderr = new Buffer(0);
14+
15+
process.stdout.on('data', function(data){
16+
stdout = Buffer.concat([stdout, new Buffer(data)]);
17+
});
18+
19+
process.stderr.on('data', function(data){
20+
stderr = Buffer.concat([stderr, new Buffer(data)]);
21+
});
22+
23+
process.on('close', function(code){
24+
if (code !== 0) errback(new Error(Buffer.concat([stdout, stderr]).toString()))();
25+
else callback(stdout.toString())();
26+
});
27+
};
28+
}
29+
30+
exports.spawnFn = spawnFn;

src/ChildProcess.purs

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module GulpPurescript.ChildProcess
33
, spawn
44
) where
55

6+
import Prelude
7+
68
import Control.Monad.Aff (Aff(), makeAff)
79
import Control.Monad.Eff (Eff())
810
import Control.Monad.Eff.Exception (Error())
@@ -11,36 +13,11 @@ import Data.Function
1113

1214
foreign import data ChildProcess :: !
1315

14-
spawn :: forall eff. String -> [String] -> Aff (cp :: ChildProcess | eff) String
16+
spawn :: forall eff. String -> Array String -> Aff (cp :: ChildProcess | eff) String
1517
spawn command args = makeAff $ runFn4 spawnFn command args
1618

17-
foreign import spawnFn """
18-
function spawnFn(command, args, errback, callback) {
19-
return function(){
20-
var child_process = require('cross-spawn');
21-
22-
var process = child_process.spawn(command, args);
23-
24-
var stdout = new Buffer(0);
25-
26-
var stderr = new Buffer(0);
27-
28-
process.stdout.on('data', function(data){
29-
stdout = Buffer.concat([stdout, new Buffer(data)]);
30-
});
31-
32-
process.stderr.on('data', function(data){
33-
stderr = Buffer.concat([stderr, new Buffer(data)]);
34-
});
35-
36-
process.on('close', function(code){
37-
if (code !== 0) errback(new Error(Buffer.concat([stdout, stderr]).toString()))();
38-
else callback(stdout.toString())();
39-
});
40-
};
41-
}
42-
""" :: forall eff. Fn4 String
43-
[String]
44-
(Error -> Eff (cp :: ChildProcess | eff) Unit)
45-
(String -> Eff (cp :: ChildProcess | eff) Unit)
46-
(Eff (cp :: ChildProcess | eff) Unit)
19+
foreign import spawnFn :: forall eff. Fn4 String
20+
(Array String)
21+
(Error -> Eff (cp :: ChildProcess | eff) Unit)
22+
(String -> Eff (cp :: ChildProcess | eff) Unit)
23+
(Eff (cp :: ChildProcess | eff) Unit)

src/Glob.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
// module GulpPurescript.Glob
4+
5+
var glob = require('glob');
6+
7+
var async = require('async');
8+
9+
function globFn(pattern, errback, callback) {
10+
return function(){
11+
glob(pattern, function(error, result){
12+
if (error) errback(new Error(error))();
13+
else callback(result)();
14+
});
15+
};
16+
}
17+
18+
function globAllFn(patterns, errback, callback) {
19+
return function(){
20+
async.map(patterns, glob, function(error, result){
21+
if (error) errback(new Error(error))();
22+
else callback(result)();
23+
});
24+
};
25+
}
26+
27+
exports.globFn = globFn;
28+
29+
exports.globAllFn = globAllFn;

src/Glob.purs

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module GulpPurescript.Glob
44
, globAll
55
) where
66

7+
import Prelude
8+
79
import Control.Monad.Aff (Aff(), makeAff)
810
import Control.Monad.Eff (Eff())
911
import Control.Monad.Eff.Exception (Error())
@@ -12,42 +14,18 @@ import Data.Function
1214

1315
foreign import data Glob :: !
1416

15-
glob :: forall eff. String -> Aff (glob :: Glob | eff) [String]
17+
glob :: forall eff. String -> Aff (glob :: Glob | eff) (Array String)
1618
glob pattern = makeAff $ runFn3 globFn pattern
1719

18-
foreign import globFn """
19-
function globFn(pattern, errback, callback) {
20-
return function(){
21-
var glob = require('glob');
22-
23-
glob(pattern, function(error, result){
24-
if (error) errback(new Error(error))();
25-
else callback(result)();
26-
});
27-
};
28-
}
29-
""" :: forall eff. Fn3 String
30-
(Error -> Eff (glob :: Glob | eff) Unit)
31-
([String] -> Eff (glob :: Glob | eff) Unit)
32-
(Eff (glob :: Glob | eff) Unit)
33-
34-
globAll :: forall eff. [String] -> Aff (glob :: Glob | eff) [[String]]
20+
foreign import globFn :: forall eff. Fn3 String
21+
(Error -> Eff (glob :: Glob | eff) Unit)
22+
(Array String -> Eff (glob :: Glob | eff) Unit)
23+
(Eff (glob :: Glob | eff) Unit)
24+
25+
globAll :: forall eff. Array String -> Aff (glob :: Glob | eff) (Array (Array String))
3526
globAll patterns = makeAff $ runFn3 globAllFn patterns
3627

37-
foreign import globAllFn """
38-
function globAllFn(patterns, errback, callback) {
39-
return function(){
40-
var glob = require('glob');
41-
42-
var async = require('async');
43-
44-
async.map(patterns, glob, function(error, result){
45-
if (error) errback(new Error(error))();
46-
else callback(result)();
47-
});
48-
};
49-
}
50-
""" :: forall eff. Fn3 [String]
51-
(Error -> Eff (glob :: Glob | eff) Unit)
52-
([[String]] -> Eff (glob :: Glob | eff) Unit)
53-
(Eff (glob :: Glob | eff) Unit)
28+
foreign import globAllFn :: forall eff. Fn3 (Array String)
29+
(Error -> Eff (glob :: Glob | eff) Unit)
30+
((Array (Array String)) -> Eff (glob :: Glob | eff) Unit)
31+
(Eff (glob :: Glob | eff) Unit)

src/GulpUtil.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
// module GulpPurescript.GulpUtil
4+
5+
var gutil = require('gulp-util');
6+
7+
function mkPluginErrorFn(name, message) {
8+
return new gutil.PluginError(name, message);
9+
}
10+
11+
function mkFileFn(path, contents) {
12+
return new gutil.File({path: path, contents: contents});
13+
}
14+
15+
exports.mkPluginErrorFn = mkPluginErrorFn;
16+
17+
exports.mkFileFn = mkFileFn;

src/GulpUtil.purs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,9 @@ data File
1515
mkPluginError :: String -> String -> Error
1616
mkPluginError name msg = runFn2 mkPluginErrorFn name msg
1717

18-
foreign import mkPluginErrorFn """
19-
function mkPluginErrorFn(name, message) {
20-
var gutil = require('gulp-util');
21-
return new gutil.PluginError(name, message);
22-
}
23-
""" :: Fn2 String String Error
18+
foreign import mkPluginErrorFn :: Fn2 String String Error
2419

2520
mkFile :: String -> Buffer -> File
2621
mkFile path contents = runFn2 mkFileFn path contents
2722

28-
foreign import mkFileFn """
29-
function mkFileFn(path, contents) {
30-
var gutil = require('gulp-util');
31-
return new gutil.File({path: path, contents: contents});
32-
}
33-
""" :: Fn2 String Buffer File
23+
foreign import mkFileFn :: Fn2 String Buffer File

0 commit comments

Comments
 (0)