prettier 1.5.4 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/README.md +5 -6
- data/node_modules/prettier/index.js +53 -53
- data/node_modules/prettier/parser-angular.js +46 -0
- data/node_modules/prettier/parser-babel.js +1 -0
- data/node_modules/prettier/parser-espree.js +1 -0
- data/node_modules/prettier/parser-flow.js +1 -0
- data/node_modules/prettier/parser-glimmer.js +1 -0
- data/node_modules/prettier/parser-graphql.js +1 -0
- data/node_modules/prettier/parser-html.js +113 -0
- data/node_modules/prettier/parser-markdown.js +19 -0
- data/node_modules/prettier/parser-meriyah.js +1 -0
- data/node_modules/prettier/parser-postcss.js +1 -0
- data/node_modules/prettier/parser-typescript.js +1 -0
- data/node_modules/prettier/parser-yaml.js +15 -0
- data/package.json +1 -1
- data/src/haml/nodes/tag.js +45 -6
- data/src/haml/parser.rb +8 -1
- data/src/parser/parseSync.js +133 -6
- data/src/rbs/parser.rb +7 -1
- data/src/rbs/printer.js +14 -4
- data/src/ruby/nodes/args.js +1 -1
- data/src/ruby/parser.rb +2 -2
- metadata +15 -6
- data/src/parser/getLang.js +0 -32
- data/src/parser/getNetcat.js +0 -57
- data/src/parser/requestParse.js +0 -74
data/src/parser/getNetcat.js
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
const { spawnSync } = require("child_process");
|
2
|
-
const os = require("os");
|
3
|
-
|
4
|
-
// Checks to see if an executable is available.
|
5
|
-
function hasCommand(name) {
|
6
|
-
let result;
|
7
|
-
|
8
|
-
if (os.type() === "Windows_NT") {
|
9
|
-
result = spawnSync("where", [name]);
|
10
|
-
} else {
|
11
|
-
result = spawnSync("command", ["-v", name]);
|
12
|
-
}
|
13
|
-
|
14
|
-
return result.status === 0;
|
15
|
-
}
|
16
|
-
|
17
|
-
// Finds an netcat-like adapter to use for sending data to a socket. We order
|
18
|
-
// these by likelihood of being found so we can avoid some shell-outs.
|
19
|
-
function getCommandAndArgs() {
|
20
|
-
if (hasCommand("nc")) {
|
21
|
-
return ["nc", ["-U"]];
|
22
|
-
}
|
23
|
-
|
24
|
-
if (hasCommand("telnet")) {
|
25
|
-
return ["telnet", ["-u"]];
|
26
|
-
}
|
27
|
-
|
28
|
-
if (hasCommand("ncat")) {
|
29
|
-
return ["ncat", ["-U"]];
|
30
|
-
}
|
31
|
-
|
32
|
-
if (hasCommand("socat")) {
|
33
|
-
return ["socat", ["-"]];
|
34
|
-
}
|
35
|
-
|
36
|
-
return ["node", [require.resolve("./netcat.js")]];
|
37
|
-
}
|
38
|
-
|
39
|
-
let command;
|
40
|
-
let args;
|
41
|
-
|
42
|
-
function getNetcat(opts) {
|
43
|
-
if (!command) {
|
44
|
-
if (opts.rubyNetcatCommand) {
|
45
|
-
const splits = opts.rubyNetcatCommand.split(" ");
|
46
|
-
|
47
|
-
command = splits[0];
|
48
|
-
args = splits.slice(1);
|
49
|
-
} else {
|
50
|
-
[command, args] = getCommandAndArgs();
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
return { command, args };
|
55
|
-
}
|
56
|
-
|
57
|
-
module.exports = getNetcat;
|
data/src/parser/requestParse.js
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
const { spawn, spawnSync, execSync } = require("child_process");
|
2
|
-
const path = require("path");
|
3
|
-
const { existsSync, mkdtempSync } = require("fs");
|
4
|
-
const process = require("process");
|
5
|
-
const os = require("os");
|
6
|
-
|
7
|
-
const getNetcat = require("./getNetcat");
|
8
|
-
const getLang = require("./getLang");
|
9
|
-
|
10
|
-
let sockfile = process.env.PRETTIER_RUBY_HOST;
|
11
|
-
|
12
|
-
// Spawn the parser.rb subprocess. We do this since booting Ruby is slow, and we
|
13
|
-
// can re-use the parser process multiple times since it is statelesss.
|
14
|
-
function spawnParseServer() {
|
15
|
-
const server = spawn(
|
16
|
-
"ruby",
|
17
|
-
[path.join(__dirname, "./server.rb"), sockfile],
|
18
|
-
{
|
19
|
-
env: Object.assign({}, process.env, { LANG: getLang() }),
|
20
|
-
detached: true,
|
21
|
-
stdio: "inherit"
|
22
|
-
}
|
23
|
-
);
|
24
|
-
|
25
|
-
process.on("exit", () => {
|
26
|
-
try {
|
27
|
-
process.kill(-server.pid);
|
28
|
-
} catch (e) {
|
29
|
-
// ignore
|
30
|
-
}
|
31
|
-
});
|
32
|
-
|
33
|
-
server.unref();
|
34
|
-
const now = new Date();
|
35
|
-
|
36
|
-
// Wait for server to go live.
|
37
|
-
while (!existsSync(sockfile) && new Date() - now < 3000) {
|
38
|
-
execSync("sleep 0.1");
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
// Ensures that a parser server is currently running by checking against the
|
43
|
-
// sockfile variable. If it is not, create a temporary directory to house the
|
44
|
-
// sockfile and spawn the ruby process.
|
45
|
-
function ensureParseServer() {
|
46
|
-
if (sockfile) {
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
|
50
|
-
const tmpDir = mkdtempSync(path.join(os.tmpdir(), "prettier-ruby"));
|
51
|
-
sockfile = path.join(tmpDir, `${process.pid}.sock`);
|
52
|
-
|
53
|
-
spawnParseServer();
|
54
|
-
}
|
55
|
-
|
56
|
-
// Sends a request to the parse server to parse the given content.
|
57
|
-
function requestParse(parser, source, opts) {
|
58
|
-
ensureParseServer();
|
59
|
-
|
60
|
-
const { command, args } = getNetcat(opts);
|
61
|
-
const { stdout, stderr, status } = spawnSync(command, args.concat(sockfile), {
|
62
|
-
input: `${parser}|${source}`,
|
63
|
-
maxBuffer: 15 * 1024 * 1024
|
64
|
-
});
|
65
|
-
|
66
|
-
return {
|
67
|
-
command,
|
68
|
-
stdout: stdout.toString(),
|
69
|
-
stderr: stderr.toString(),
|
70
|
-
status
|
71
|
-
};
|
72
|
-
}
|
73
|
-
|
74
|
-
module.exports = requestParse;
|