-
-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove native JavaScript Gherkin parser - delegate to Go executable (#…
…448) * Remove native JavaScript Gherkin parser - delegate to Go executable * misc js build improvements * Prettify js
- Loading branch information
1 parent
3602f00
commit 8b85909
Showing
84 changed files
with
9,377 additions
and
16,810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 8 | ||
}, | ||
"plugins": [ | ||
"prettier" | ||
], | ||
"rules": { | ||
"prettier/prettier": [ | ||
"error", {"trailingComma": "es5", "singleQuote": true, "semi": false} | ||
] | ||
}, | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"prettier" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.idea/ | ||
.nyc_output/ | ||
coverage/ | ||
dist/ | ||
node_modules/ | ||
yarn.lock | ||
npm-debug.log | ||
package-lock.json | ||
.deps | ||
.tested | ||
.eslinted | ||
acceptance | ||
*-go/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var path = require('path') | ||
var fs = require('fs') | ||
var exec = require('child_process').exec | ||
|
||
fs.access(path.join(__dirname, '..', 'dist'), function(err) { | ||
if (!err) return | ||
exec('yarn build', { cwd: path.join(__dirname, '..') }, function(err) { | ||
if (err) throw err | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ dist/ | |
node_modules/ | ||
yarn.lock | ||
npm-debug.log | ||
build/ | ||
package-lock.json | ||
.deps | ||
.tested | ||
.eslinted | ||
acceptance | ||
*-go/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 8 | ||
}, | ||
"plugins": [ | ||
"prettier" | ||
], | ||
"rules": { | ||
"prettier/prettier": [ | ||
"error", {"trailingComma": "es5", "singleQuote": true, "semi": false} | ||
] | ||
}, | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"prettier" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
acceptance/ | ||
.idea/ | ||
.nyc_output/ | ||
coverage/ | ||
dist/ | ||
node_modules/ | ||
npm-debug.log | ||
yarn.lock | ||
npm-debug.log | ||
package-lock.json | ||
.deps | ||
.tested | ||
.eslinted | ||
acceptance | ||
*-go/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
berp | ||
examples | ||
test | ||
testdata | ||
.gitrepo | ||
*.razor | ||
*.berp | ||
Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[![Build Status](https://secure.travis-ci.org/cucumber/gherkin-javascript.svg)](http://travis-ci.org/cucumber/gherkin-javascript) | ||
|
||
Gherkin parser/compiler for JavaScript. Please see [Gherkin](https://github.com/cucumber/gherkin) for details. | ||
Gherkin parser/compiler for JavaScript. Please see [Gherkin](https://github.com/cucumber/cucumber/tree/master/gherkin) for details. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,48 @@ | ||
#!/usr/bin/env node | ||
'use strict' | ||
var Stream = require('stream') | ||
var fs = require('fs') | ||
var m = require('cucumber-messages').io.cucumber.messages | ||
var SourceStream = require('../lib/gherkin/messages/source_stream') | ||
var MessageStream = require('../lib/gherkin/messages/message_stream') | ||
var ProtobufMessageStream = require('../lib/gherkin/messages/protobuf_message_stream') | ||
var args = process.argv.slice(2) | ||
var options = { | ||
const Stream = require('stream') | ||
const Gherkin = require('../src/Gherkin') | ||
const args = process.argv.slice(2) | ||
const options = { | ||
includeSource: true, | ||
includeGherkinDocument: true, | ||
includePickles: true, | ||
protobuf: false | ||
} | ||
|
||
var paths = [] | ||
const paths = [] | ||
while (args.length > 0) { | ||
var arg = args.shift() | ||
const arg = args.shift() | ||
switch (arg) { | ||
case '--no-source': | ||
options.includeSource = false; | ||
break; | ||
options.includeSource = false | ||
break | ||
|
||
case '--no-ast': | ||
options.includeGherkinDocument = false; | ||
break; | ||
options.includeGherkinDocument = false | ||
break | ||
|
||
case '--no-pickles': | ||
options.includePickles = false; | ||
break; | ||
|
||
case '--protobuf': | ||
options.protobuf = true; | ||
break; | ||
options.includePickles = false | ||
break | ||
|
||
default: | ||
paths.push(arg); | ||
paths.push(arg) | ||
} | ||
} | ||
|
||
function pipeMessagesTo(paths, i, stream) { | ||
var path = paths[i++] | ||
if (!path) { | ||
return stream.end() | ||
const protobufNdsonStream = new Stream.Transform({ | ||
objectMode: true, | ||
transform: function (message, _, callback) { | ||
const ob = message.constructor.toObject(message, {defaults: true}) | ||
// This reviver omits printing fields with empty values | ||
// This is to make it behave the same as Golang's protobuf->JSON converter | ||
const json = JSON.stringify(ob, function (key, value) { | ||
return (value === null) || (value === "") || (value === 0) || (Array.isArray(value) && value.length === 0) ? undefined : value | ||
}) | ||
this.push(json + "\n") | ||
callback() | ||
} | ||
var messageStream = createMessageStream(path) | ||
messageStream.pipe(stream, {end: false}) | ||
messageStream.on('end', () => pipeMessagesTo(paths, i, stream)) | ||
} | ||
|
||
function createMessageStream(path) { | ||
return fs.createReadStream(path, {encoding: 'UTF-8'}) | ||
.pipe(new SourceStream(path)) | ||
.pipe(new MessageStream(options)) | ||
} | ||
}) | ||
|
||
var messageTransformerStream | ||
if (options.protobuf) { | ||
messageTransformerStream = new Stream.Transform({ | ||
objectMode: true, | ||
transform: function (message, _, callback) { | ||
var buffer = message.constructor.encodeDelimited(message).finish() | ||
this.push(buffer) | ||
callback() | ||
} | ||
}) | ||
} else { | ||
messageTransformerStream = new Stream.Transform({ | ||
objectMode: true, | ||
transform: function (message, _, callback) { | ||
var ob = message.constructor.toObject(message, {defaults: true}) | ||
// This reviver omits printing fields with empty values | ||
// This is to make it behave the same as Golang's protobuf->JSON converter | ||
var json = JSON.stringify(ob, function (key, value) { | ||
return (value === null) || (value === "") || (value === 0) || (Array.isArray(value) && value.length === 0) ? undefined : value | ||
}); | ||
this.push(json + "\n") | ||
callback() | ||
} | ||
}) | ||
} | ||
|
||
messageTransformerStream.pipe(process.stdout) | ||
|
||
if (paths.length > 0) { | ||
pipeMessagesTo(paths, 0, messageTransformerStream) | ||
} else { | ||
process.stdin.pipe(new ProtobufMessageStream(m.Wrapper)).pipe(messageTransformerStream) | ||
} | ||
const gherkin = new Gherkin(paths, [], options) | ||
gherkin.messages().pipe(protobufNdsonStream).pipe(process.stdout) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.