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

Commit a62e8f6

Browse files
committed
Merge pull request #44 from purescript-contrib/0.7-stream-updates
Merging stream refactoring for 0.7 updates.
2 parents c76e143 + c8fb297 commit a62e8f6

14 files changed

+288
-365
lines changed

MODULE.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,47 @@ multipipe2 :: forall a b c. Stream a b -> Stream b c -> Stream a c
140140

141141

142142

143+
## Module GulpPurescript.OS
144+
145+
#### `OS`
146+
147+
``` purescript
148+
data OS :: !
149+
```
150+
151+
152+
#### `Platform`
153+
154+
``` purescript
155+
data Platform
156+
= Darwin
157+
| Linux
158+
| Win32
159+
```
160+
161+
162+
#### `showPlatform`
163+
164+
``` purescript
165+
instance showPlatform :: Show Platform
166+
```
167+
168+
169+
#### `isForeignPlatform`
170+
171+
``` purescript
172+
instance isForeignPlatform :: IsForeign Platform
173+
```
174+
175+
176+
#### `platform`
177+
178+
``` purescript
179+
platform :: forall eff. Eff (os :: OS | eff) (Maybe Platform)
180+
```
181+
182+
183+
143184
## Module GulpPurescript.Options
144185

145186
#### `isForeignEither`
@@ -269,47 +310,6 @@ pscDocsOptions :: Foreign -> Either ForeignError [String]
269310

270311

271312

272-
## Module GulpPurescript.OS
273-
274-
#### `OS`
275-
276-
``` purescript
277-
data OS :: !
278-
```
279-
280-
281-
#### `Platform`
282-
283-
``` purescript
284-
data Platform
285-
= Darwin
286-
| Linux
287-
| Win32
288-
```
289-
290-
291-
#### `showPlatform`
292-
293-
``` purescript
294-
instance showPlatform :: Show Platform
295-
```
296-
297-
298-
#### `isForeignPlatform`
299-
300-
``` purescript
301-
instance isForeignPlatform :: IsForeign Platform
302-
```
303-
304-
305-
#### `platform`
306-
307-
``` purescript
308-
platform :: forall eff. Eff (os :: OS | eff) (Maybe Platform)
309-
```
310-
311-
312-
313313
## Module GulpPurescript.Package
314314

315315
#### `Pkg`
@@ -389,10 +389,10 @@ pscDocs :: forall eff. Foreign -> (Error -> Eff (Effects eff) Unit) -> (File ->
389389
```
390390

391391

392-
#### `dotPsci`
392+
#### `psci`
393393

394394
``` purescript
395-
dotPsci :: forall eff. Eff (Effects eff) (Stream File Unit)
395+
psci :: forall eff. Eff (Effects eff) (Stream File Unit)
396396
```
397397

398398

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ var gulp = require('gulp');
2121

2222
var purescript = require('gulp-purescript');
2323

24-
gulp.task('purescript', function(){
25-
return gulp.src('src/**/*.purs').
26-
pipe(purescript.psc({noPrelude: true})).
27-
pipe(gulp.dest('build'));
24+
gulp.task('psc', function(){
25+
return purescript.psc({
26+
src: 'src/*.purs'
27+
});
2828
});
2929
```
3030

@@ -38,11 +38,11 @@ Invokes the `psc` command. The following options are supported.
3838

3939
###### `src` (String or String Array)
4040

41-
The location of the source files to compile. Glob syntax is supported.
41+
Files to compile. Glob syntax is supported.
4242

4343
###### `ffi` (String or String Array)
4444

45-
Sets one or more `--ffi=<string>` that specifies files for code that is included with a `foreign import` in the PureScript source.
45+
Files for code that is included with a `foreign import` in the PureScript source. Glob syntax is supported.
4646

4747
###### `noTco` (Boolean)
4848

@@ -78,7 +78,7 @@ Invokes the `psc-bundle` command. The following options are supported.
7878

7979
###### `src` (String or String Array)
8080

81-
The location of the `psc`-produced javascript source files to bundle. Glob syntax is supported.
81+
The `psc`-produced JavaScript source files to bundle. Glob syntax is supported.
8282

8383
###### `output` (String)
8484

@@ -98,7 +98,11 @@ Sets `--browser-namespace=<string>` that specifies the namespace that PureScript
9898

9999
### `purescript.pscDocs(options)`
100100

101-
Invokes the `pscDocs` command. The following options are supported.
101+
Invokes the `psc-docs` command. The following options are supported.
102+
103+
###### `src` (String or String Array)
104+
105+
Files to be used for generating the documentation. Glob syntax is supported.
102106

103107
###### `format` (markdown | etags | ctags)
104108

@@ -110,11 +114,19 @@ Sets `--docgen=...` that can be used to filter the modules documentation is gene
110114

111115
- If a string value is provided, the documentation for that single module will be generated.
112116
- If a list of strings is provided, the documentation for all listed modules will be generated.
113-
- If an object with module name/filename pairs (for example, `{ Module: "docs/Module.md" }`) is provided, files will be written for each of the modules. In this mode, the task requires no `dest` as no value is returned.
117+
- If an object with module name/filename pairs (for example, `{ Module: 'docs/Module.md' }`) is provided, files will be written for each of the modules. In this mode, the task requires no `dest` as no value is returned.
118+
119+
### `purescript.psci(options)`
120+
121+
Generates a `.psci` file.
114122

115-
### `purescript.dotPsci()`
123+
###### `src` (String or String Array)
124+
125+
Files added to the `.psci` file with the `:m` command. Glob syntax is supported.
126+
127+
###### `ffi` (String or String Array)
116128

117-
Generates a `.psci` file in the current directory. Each source file is added with the `:m` command.
129+
Files added to the `.psci` file with the `:f` command. Glob syntax is supported.
118130

119131
## Command line arguments
120132

entry.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,21 @@
11
'use strict';
22

33
var gulpPurescript = require('GulpPurescript.Plugin');
4-
var Promise = require('promise');
5-
6-
function promisify(aff) {
7-
return new Promise(function (resolve, reject) {
8-
var errback = function (err) {
9-
return function () {
10-
reject(err);
11-
};
12-
};
13-
var callback = function (x) {
14-
return function () {
15-
resolve(x);
16-
};
17-
};
18-
aff(errback)(callback)();
19-
});
20-
}
214

225
function psc(options) {
23-
return promisify(gulpPurescript.psc(options));
6+
return gulpPurescript.psc(options)();
247
}
258

269
function pscBundle(options) {
27-
return promisify(gulpPurescript.pscBundle(options));
10+
return gulpPurescript.pscBundle(options)();
2811
}
2912

3013
function pscDocs(options) {
31-
return promisify(gulpPurescript.pscDocs(options));
14+
return gulpPurescript.pscDocs(options)();
3215
}
3316

34-
function dotPsci() {
35-
var result = gulpPurescript.dotPsci();
36-
return result;
17+
function psci(options) {
18+
return gulpPurescript.psci(options)();
3719
}
3820

3921
module.exports.psc = psc;
@@ -42,4 +24,4 @@ module.exports.pscBundle = pscBundle;
4224

4325
module.exports.pscDocs = pscDocs;
4426

45-
module.exports.dotPsci = dotPsci;
27+
module.exports.psci = psci;

foreign.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
function test(){
2+
}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@
2929
"purescript"
3030
],
3131
"dependencies": {
32+
"async": "^1.3.0",
3233
"cross-spawn": "^0.4.0",
3334
"glob": "^5.0.5",
3435
"gulp-util": "^3.0.4",
3536
"logalot": "^2.1.0",
3637
"minimist": "^1.1.1",
37-
"multipipe": "^0.1.2",
38-
"promise": "^7.0.3",
3938
"resolve-bin": "^0.3.0",
40-
"through2": "^0.6.3",
4139
"which": "^1.0.9"
4240
},
4341
"devDependencies": {
@@ -49,6 +47,7 @@
4947
"run-sequence": "^1.0.2",
5048
"tap-spec": "^2.2.2",
5149
"tape": "^3.5.0",
50+
"through2": "^0.6.3",
5251
"webpack": "^1.8.9"
5352
}
5453
}

src/FS.purs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Glob.purs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module GulpPurescript.Glob
2+
( Glob()
3+
, glob
4+
, globAll
5+
) where
6+
7+
import Control.Monad.Aff (Aff(), makeAff)
8+
import Control.Monad.Eff (Eff())
9+
import Control.Monad.Eff.Exception (Error())
10+
11+
import Data.Function
12+
13+
foreign import data Glob :: !
14+
15+
glob :: forall eff. String -> Aff (glob :: Glob | eff) [String]
16+
glob pattern = makeAff $ runFn3 globFn pattern
17+
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]]
35+
globAll patterns = makeAff $ runFn3 globAllFn patterns
36+
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)

src/GulpUtil.purs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ module GulpPurescript.GulpUtil
22
( File()
33
, mkPluginError
44
, mkFile
5-
, filePath
6-
, fileIsNull
7-
, fileIsStream
85
) where
96

107
import Control.Monad.Eff.Exception (Error())
@@ -34,21 +31,3 @@ function mkFileFn(path, contents) {
3431
return new gutil.File({path: path, contents: contents});
3532
}
3633
""" :: Fn2 String Buffer File
37-
38-
foreign import filePath """
39-
function filePath(file) {
40-
return file.path;
41-
}
42-
""" :: File -> String
43-
44-
foreign import fileIsNull"""
45-
function fileIsNull(file) {
46-
return file.isNull();
47-
}
48-
""" :: File -> Boolean
49-
50-
foreign import fileIsStream """
51-
function fileIsStream(file) {
52-
return file.isStream();
53-
}
54-
""" :: File -> Boolean

src/Multipipe.purs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)