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

Commit bfe0bfd

Browse files
committed
Glob patterns for foreign files
1 parent 9812c6f commit bfe0bfd

File tree

3 files changed

+52
-37
lines changed

3 files changed

+52
-37
lines changed

MODULE.md

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

141141

142142

143-
## Module GulpPurescript.OS
143+
## Module GulpPurescript.Options
144144

145-
#### `OS`
145+
#### `isForeignEither`
146146

147147
``` purescript
148-
data OS :: !
148+
instance isForeignEither :: (IsForeign a, IsForeign b) => IsForeign (Either a b)
149149
```
150150

151151

152-
#### `Platform`
152+
#### `isForeignPsc`
153153

154154
``` purescript
155-
data Platform
156-
= Darwin
157-
| Linux
158-
| Win32
155+
instance isForeignPsc :: IsForeign Psc
159156
```
160157

161158

162-
#### `showPlatform`
159+
#### `isForeignPscMake`
163160

164161
``` purescript
165-
instance showPlatform :: Show Platform
162+
instance isForeignPscMake :: IsForeign PscMake
166163
```
167164

168165

169-
#### `isForeignPlatform`
166+
#### `isForeignPscDocs`
170167

171168
``` purescript
172-
instance isForeignPlatform :: IsForeign Platform
169+
instance isForeignPscDocs :: IsForeign PscDocs
173170
```
174171

175172

176-
#### `platform`
173+
#### `isForeignFormat`
177174

178175
``` purescript
179-
platform :: forall eff. Eff (os :: OS | eff) (Maybe Platform)
176+
instance isForeignFormat :: IsForeign Format
180177
```
181178

182179

183-
184-
## Module GulpPurescript.Options
185-
186-
#### `isForeignEither`
180+
#### `pscOptions`
187181

188182
``` purescript
189-
instance isForeignEither :: (IsForeign a, IsForeign b) => IsForeign (Either a b)
183+
pscOptions :: Foreign -> [String]
190184
```
191185

192186

193-
#### `isForeignPsc`
187+
#### `pscOptionsNoOutput`
194188

195189
``` purescript
196-
instance isForeignPsc :: IsForeign Psc
190+
pscOptionsNoOutput :: Foreign -> Tuple (Maybe String) [String]
197191
```
198192

199193

200-
#### `isForeignPscMake`
194+
#### `pscMakeOptions`
201195

202196
``` purescript
203-
instance isForeignPscMake :: IsForeign PscMake
197+
pscMakeOptions :: Foreign -> [String]
204198
```
205199

206200

207-
#### `isForeignPscDocs`
201+
#### `pscDocsOptions`
208202

209203
``` purescript
210-
instance isForeignPscDocs :: IsForeign PscDocs
204+
pscDocsOptions :: Foreign -> [String]
211205
```
212206

213207

214-
#### `isForeignFormat`
208+
209+
## Module GulpPurescript.OS
210+
211+
#### `OS`
215212

216213
``` purescript
217-
instance isForeignFormat :: IsForeign Format
214+
data OS :: !
218215
```
219216

220217

221-
#### `pscOptions`
218+
#### `Platform`
222219

223220
``` purescript
224-
pscOptions :: Foreign -> [String]
221+
data Platform
222+
= Darwin
223+
| Linux
224+
| Win32
225225
```
226226

227227

228-
#### `pscOptionsNoOutput`
228+
#### `showPlatform`
229229

230230
``` purescript
231-
pscOptionsNoOutput :: Foreign -> Tuple (Maybe String) [String]
231+
instance showPlatform :: Show Platform
232232
```
233233

234234

235-
#### `pscMakeOptions`
235+
#### `isForeignPlatform`
236236

237237
``` purescript
238-
pscMakeOptions :: Foreign -> [String]
238+
instance isForeignPlatform :: IsForeign Platform
239239
```
240240

241241

242-
#### `pscDocsOptions`
242+
#### `platform`
243243

244244
``` purescript
245-
pscDocsOptions :: Foreign -> [String]
245+
platform :: forall eff. Eff (os :: OS | eff) (Maybe Platform)
246246
```
247247

248248

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"purescript"
3030
],
3131
"dependencies": {
32+
"glob": "^5.0.5",
3233
"gulp-util": "^3.0.4",
3334
"logalot": "^2.1.0",
3435
"minimist": "^1.1.1",

src/Options.purs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,20 @@ mkStringArray :: String -> NullOrUndefined [String] -> [String]
193193
mkStringArray key opt = concat $ mkString key <$> (NullOrUndefined <<< Just)
194194
<$> (fromMaybe [] $ runNullOrUndefined opt)
195195

196+
mkPathArray :: String -> NullOrUndefined [String] -> [String]
197+
mkPathArray key opt = concat $ mkString key <$> (NullOrUndefined <<< Just)
198+
<$> (fromMaybe [] (runNullOrUndefined opt) >>= expandGlob)
199+
200+
foreign import expandGlob
201+
"""
202+
var expandGlob = (function () {
203+
var glob = require("glob");
204+
return function (pattern) {
205+
return glob.sync(pattern);
206+
};
207+
}());
208+
""" :: String -> [String]
209+
196210
mkFormat :: String -> NullOrUndefined Format -> [String]
197211
mkFormat key opt = mkString key (maybe j (\a -> case a of
198212
Markdown -> i "markdown"
@@ -215,7 +229,7 @@ foldPscOptions (Psc a) = mkBoolean noPreludeOpt a.noPrelude <>
215229
mkString outputOpt a.output <>
216230
mkString externsOpt a.externs <>
217231
mkBoolean noPrefixOpt a.noPrefix <>
218-
mkStringArray ffiOpt a.ffi
232+
mkPathArray ffiOpt a.ffi
219233

220234
pscOptions :: Foreign -> [String]
221235
pscOptions opts = either (const []) foldPscOptions parsed
@@ -238,7 +252,7 @@ pscMakeOptions opts = either (const []) fold parsed
238252
mkBoolean verboseErrorsOpt a.verboseErrors <>
239253
mkBoolean commentsOpt a.comments <>
240254
mkBoolean noPrefixOpt a.noPrefix <>
241-
mkStringArray ffiOpt a.ffi
255+
mkPathArray ffiOpt a.ffi
242256

243257
pscDocsOptions :: Foreign -> [String]
244258
pscDocsOptions opts = either (const []) fold parsed

0 commit comments

Comments
 (0)