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

Commit 55caaf4

Browse files
committed
Using omit to filter the output key
1 parent 191399f commit 55caaf4

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

index.js

Lines changed: 9 additions & 10 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,16 +67,14 @@ function acc(f) {
6667
}
6768

6869
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-
}
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.
7776
return acc(function(files, cb){
78-
var args = files.concat(options(OPTIONS.psc, opts))
77+
var args = files.concat(options(OPTIONS.psc, opts$prime))
7978
, cmd = cp.spawn('psc', args)
8079
, buffer = new Buffer(0)
8180
, that = this
@@ -88,7 +87,7 @@ function psc(opts) {
8887
if (!!code) that.emit('error', new gutil.PluginError(PLUGIN, buffer.toString()));
8988
else {
9089
that.push(new gutil.File({
91-
path: (output || 'psc.js'),
90+
path: output,
9291
contents: buffer
9392
}));
9493
}

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ it('should compile purescript', function(cb){
1313

1414
stream.on('data', function(file){
1515
assert(/Fixture/.test(file.contents.toString()));
16+
assert.equal('psc.js', file.path);
1617
cb();
1718
});
1819

0 commit comments

Comments
 (0)