Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jison-gho dependency #3915

Merged
merged 2 commits into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.coverage
flow-typed
lib/vendor
lib/utils/parseCalcExpression/parser.js
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.coverage
flow-typed
lib/utils/parseCalcExpression/parser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const parse = require("../parseCalcExpression");
const parse = require("..");

it("parseCalcExpression parse to ast", () => {
expect(parse("calc(100% - 80px)")).toEqual({
Expand Down
20 changes: 6 additions & 14 deletions lib/utils/parseCalcExpression/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
"use strict";

const fs = require("fs");
const jison = require("jison-gho");
// To generate parser.js run the following command in the current directory:
//
// npx jison-gho parser.jison -o parser.js

let parser;
const parse = require("./parser").parse;

module.exports = function(exp) {
if (!parser) {
const parserConfig = fs.readFileSync(
require.resolve("./parser.jison"),
"utf8"
);

parser = new jison.Parser(parserConfig);
}

return parser.parse(exp);
module.exports = function parseCalcExpression(exp) {
return parse(exp);
};