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

Commit 558b27b

Browse files
committed
Merge branch 'fujimura-allow-output'
2 parents ce1c227 + b9f5286 commit 558b27b

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Invokes the `psc` command.
4646
- externs: String value that sets `--externs=<string>`
4747
- modules: String or array value that sets one or more `--module=<string>`
4848
- codegen: String or array value that sets one or more `--codegen=<string>`
49+
- output: String value that sets `--output=<string>`
4950

5051
### purescript.pscMake(options)
5152

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var gutil = require('gulp-util')
1515
main: '--main',
1616
verboseErrors: '--verbose-errors'
1717
}
18-
, single: {browserNamespace: '--browser-namespace', externs: '--externs', main: '--main'}
18+
, single: {browserNamespace: '--browser-namespace', externs: '--externs', main: '--main', output: '--output'}
1919
, multi: {modules: '--module', codegen: '--codegen'}
2020
},
2121
pscMake: {
@@ -80,7 +80,7 @@ function psc(opts) {
8080
if (!!code) that.emit('error', new gutil.PluginError(PLUGIN, buffer.toString()));
8181
else {
8282
that.push(new gutil.File({
83-
path: 'psc.js',
83+
path: (opts.output || 'psc.js'),
8484
contents: buffer
8585
}));
8686
}

test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var gutil = require('gulp-util')
44
, assert = require('assert')
55
, fs = require('fs')
66
, purescript = require('./')
7+
, os = require('os')
78
;
89

910
it('should compile purescript', function(cb){
@@ -30,3 +31,29 @@ it('should compile purescript', function(cb){
3031
}
3132
});
3233
});
34+
35+
it('should compile purescript to specified output', function(cb){
36+
var fixture = 'Fixture.purs.hs'
37+
, output = os.tmpdir() + '/output.js'
38+
, stream = purescript.psc({noPrelude: true, output: output})
39+
;
40+
41+
stream.on('data', function(file){
42+
assert.equal(output, file.path);
43+
cb();
44+
});
45+
46+
fs.readFile(fixture, function(e, buffer){
47+
if (e) cb(assert(false));
48+
else {
49+
stream.write(new gutil.File({
50+
cwd: __dirname,
51+
base: __dirname,
52+
path: __dirname + '/' + fixture,
53+
contents: buffer,
54+
stat: {mtime: new Date()}
55+
}));
56+
stream.end();
57+
}
58+
});
59+
});

0 commit comments

Comments
 (0)