src/rbs/parser.js in prettier-1.3.0 vs src/rbs/parser.js in prettier-1.4.0
- old
+ new
@@ -1,24 +1,12 @@
-const { spawnSync } = require("child_process");
-const path = require("path");
+const parseSync = require("../parser/parseSync");
// This function is responsible for taking an input string of text and returning
// to prettier a JavaScript object that is the equivalent AST that represents
// the code stored in that string. We accomplish this by spawning a new Ruby
// process of parser.rb and reading JSON off STDOUT.
function parse(text, _parsers, _opts) {
- const child = spawnSync("ruby", [path.join(__dirname, "./parser.rb")], {
- input: text,
- maxBuffer: 15 * 1024 * 1024 // 15MB
- });
-
- const error = child.stderr.toString();
- if (error) {
- throw new Error(error);
- }
-
- const response = child.stdout.toString();
- return JSON.parse(response);
+ return parseSync("rbs", text);
}
const pragmaPattern = /#\s*@(prettier|format)/;
// This function handles checking whether or not the source string has the