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

Commit 10afc3d

Browse files
committed
Merge branch 'fujimura-create-output-file-by-gulp-not-psc-command'
2 parents 6dd21e4 + 55caaf4 commit 10afc3d

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +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>`
49+
- output: String value that specifies the output file(this won't set'`--output=<string>`)
5050

5151
### purescript.pscMake(options)
5252

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var gutil = require('gulp-util')
44
, through = require('through2')
5+
, lodash = require('lodash')
56
, cp = require('child_process')
67
, PLUGIN = 'gulp-purescript'
78
, OPTIONS = {
@@ -66,8 +67,14 @@ function acc(f) {
6667
}
6768

6869
function psc(opts) {
70+
var output = opts && opts.output ? opts.output : 'psc.js'
71+
, opts$prime = lodash.omit(opts || {}, 'output')
72+
;
73+
// The `output` given there will be passed to gulp, not `psc` command.
74+
// If it was passed to `psc` command, the file will be created and gulp
75+
// won't receive any input stream from this function.
6976
return acc(function(files, cb){
70-
var args = files.concat(options(OPTIONS.psc, opts))
77+
var args = files.concat(options(OPTIONS.psc, opts$prime))
7178
, cmd = cp.spawn('psc', args)
7279
, buffer = new Buffer(0)
7380
, that = this
@@ -80,7 +87,7 @@ function psc(opts) {
8087
if (!!code) that.emit('error', new gutil.PluginError(PLUGIN, buffer.toString()));
8188
else {
8289
that.push(new gutil.File({
83-
path: (opts.output || 'psc.js'),
90+
path: output,
8491
contents: buffer
8592
}));
8693
}

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@
99
"email": "[email protected]"
1010
},
1111
"engineStrict": true,
12-
"engines": {"node": ">=0.10"},
13-
"files": ["index.js"],
14-
"scripts": {"test": "mocha"},
12+
"engines": {
13+
"node": ">=0.10"
14+
},
15+
"files": [
16+
"index.js"
17+
],
18+
"scripts": {
19+
"test": "mocha"
20+
},
1521
"keywords": [
1622
"gulpplugin",
1723
"purescript"
1824
],
1925
"dependencies": {
20-
"through2": "^0.4.1",
21-
"gulp-util": "^2.2.14"
26+
"gulp-util": "^2.2.14",
27+
"lodash": "^2.4.1",
28+
"through2": "^0.4.1"
2229
},
2330
"devDependencies": {
2431
"mocha": "*"

test.js

Lines changed: 4 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){
@@ -14,6 +13,7 @@ it('should compile purescript', function(cb){
1413

1514
stream.on('data', function(file){
1615
assert(/Fixture/.test(file.contents.toString()));
16+
assert.equal('psc.js', file.path);
1717
cb();
1818
});
1919

@@ -32,13 +32,14 @@ it('should compile purescript', function(cb){
3232
});
3333
});
3434

35-
it('should compile purescript to specified output', function(cb){
35+
it('should compile purescript to specified output, without creating file', function(cb){
3636
var fixture = 'Fixture.purs.hs'
37-
, output = os.tmpdir() + '/output.js'
37+
, output = 'output.js'
3838
, stream = purescript.psc({noPrelude: true, output: output})
3939
;
4040

4141
stream.on('data', function(file){
42+
assert(!fs.existsSync(__dirname + "/" + output));
4243
assert.equal(output, file.path);
4344
cb();
4445
});

0 commit comments

Comments
 (0)