This repository was archived by the owner on May 1, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +55
-0
lines changed Expand file tree Collapse file tree 4 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1
1
.DS_Store
2
2
* .log
3
+ .psci
3
4
node_modules
Original file line number Diff line number Diff line change @@ -63,6 +63,11 @@ Invokes the `psc-make` command.
63
63
- browserNamespace: String value that sets ` --browser-namespace=<string> `
64
64
- output: String value that sets ` --output=<string> `
65
65
66
+ ### purescript.dotPsci()
67
+
68
+ Generates a ` .psci ` file in the current directory. Each source file is
69
+ added with the ` :m ` command.
70
+
66
71
### purescript.docgen(options)
67
72
68
73
Invokes the ` docgen ` command.
Original file line number Diff line number Diff line change @@ -4,7 +4,12 @@ var gutil = require('gulp-util')
4
4
, through = require ( 'through2' )
5
5
, lodash = require ( 'lodash' )
6
6
, cp = require ( 'child_process' )
7
+ , fs = require ( 'fs' )
8
+ , path = require ( 'path' )
7
9
, PLUGIN = 'gulp-purescript'
10
+ , DOTPSCI = '.psci'
11
+ , LOADM = ':m'
12
+ , CWD = process . cwd ( )
8
13
, OPTIONS = {
9
14
psc : {
10
15
flags : {
@@ -121,6 +126,23 @@ function pscMake(opts) {
121
126
} ) ;
122
127
}
123
128
129
+ function dotPsci ( opts ) {
130
+ var stream = through . obj ( function ( file , env , cb ) {
131
+ if ( file . isNull ( ) ) {
132
+ this . push ( file ) ;
133
+ return cb ( ) ;
134
+ }
135
+ if ( file . isStream ( ) ) {
136
+ this . emit ( 'error' , new gutil . PluginError ( PLUGIN , 'Streaming not supported' ) ) ;
137
+ return cb ( ) ;
138
+ }
139
+ this . push ( new Buffer ( LOADM + ' ' + path . relative ( CWD , file . path ) + '\n' ) ) ;
140
+ cb ( ) ;
141
+ } ) ;
142
+ stream . pipe ( fs . createWriteStream ( DOTPSCI ) ) ;
143
+ return stream ;
144
+ }
145
+
124
146
function docgen ( opts ) {
125
147
return acc ( function ( files , cb ) {
126
148
var args = options ( OPTIONS . docgen , opts ) . concat ( files )
@@ -146,6 +168,7 @@ function docgen(opts) {
146
168
147
169
module . exports = {
148
170
docgen : docgen ,
171
+ dotPsci : dotPsci ,
149
172
psc : psc ,
150
173
pscMake : pscMake
151
174
}
Original file line number Diff line number Diff line change @@ -84,3 +84,29 @@ it('should fail to compile with an error message', function(cb){
84
84
}
85
85
} ) ;
86
86
} ) ;
87
+
88
+ it ( 'should write a .psci file' , function ( cb ) {
89
+ var stream = purescript . dotPsci ( )
90
+ , fixture = 'Fixture1.purs'
91
+ , output = ':m ' + fixture + '\n'
92
+ ;
93
+
94
+ stream . on ( 'data' , function ( line ) {
95
+ assert . equal ( output , line . toString ( ) ) ;
96
+ cb ( ) ;
97
+ } ) ;
98
+
99
+ fs . readFile ( fixture , function ( e , buffer ) {
100
+ if ( e ) cb ( assert ( false ) ) ;
101
+ else {
102
+ stream . write ( new gutil . File ( {
103
+ cwd : __dirname ,
104
+ base : __dirname ,
105
+ path : __dirname + '/' + fixture ,
106
+ contents : buffer ,
107
+ stat : { mtime : new Date ( ) }
108
+ } ) ) ;
109
+ stream . end ( ) ;
110
+ }
111
+ } ) ;
112
+ } ) ;
You can’t perform that action at this time.
0 commit comments