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

Commit 168b363

Browse files
committed
Create output file by gulp, not psc command
The `output` option given to `psc` function should be passed to gulp, not `psc` command. If it was passed to `psc` command, the file will be created and gulp won't receive any input stream from this function.
1 parent 6dd21e4 commit 168b363

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ function acc(f) {
6666
}
6767

6868
function psc(opts) {
69+
var output = undefined;
70+
if (opts.output) {
71+
output = opts.output;
72+
// The `output` given there will be passed to gulp, not `psc` command.
73+
// If it was passed to `psc` command, the file will be created and gulp
74+
// won't receive any input stream from this function.
75+
delete opts.output;
76+
}
6977
return acc(function(files, cb){
7078
var args = files.concat(options(OPTIONS.psc, opts))
7179
, cmd = cp.spawn('psc', args)
@@ -80,7 +88,7 @@ function psc(opts) {
8088
if (!!code) that.emit('error', new gutil.PluginError(PLUGIN, buffer.toString()));
8189
else {
8290
that.push(new gutil.File({
83-
path: (opts.output || 'psc.js'),
91+
path: (output || 'psc.js'),
8492
contents: buffer
8593
}));
8694
}

test.js

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

109
it('should compile purescript', function(cb){
@@ -32,13 +31,14 @@ it('should compile purescript', function(cb){
3231
});
3332
});
3433

35-
it('should compile purescript to specified output', function(cb){
34+
it('should compile purescript to specified output, without creating file', function(cb){
3635
var fixture = 'Fixture.purs.hs'
37-
, output = os.tmpdir() + '/output.js'
36+
, output = 'output.js'
3837
, stream = purescript.psc({noPrelude: true, output: output})
3938
;
4039

4140
stream.on('data', function(file){
41+
assert(!fs.existsSync(__dirname + "/" + output));
4242
assert.equal(output, file.path);
4343
cb();
4444
});

0 commit comments

Comments
 (0)