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

Support shimmed ruby versions #1407

Merged
merged 13 commits into from
Nov 23, 2023
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ file](https://prettier.io/docs/en/configuration.html).

```json
{
"plugins": ["@prettier/plugin-ruby"],
"plugins": ["@prettier/plugin-ruby"]
}
```

Expand Down
3 changes: 3 additions & 0 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export async function spawnServer(opts, killOnExit = true) {
const tmpdir = os.tmpdir();
const filepath = path.join(tmpdir, `prettier-ruby-parser-${process.pid}.txt`);

const currentFile = opts.filepath || process.cwd();

const server = spawn(
opts.rubyExecutablePath || "ruby",
[
Expand All @@ -75,6 +77,7 @@ export async function spawnServer(opts, killOnExit = true) {
filepath
],
{
cwd: path.dirname(currentFile),
env: Object.assign({}, process.env, { LANG: getLang() }),
stdio: ["ignore", "ignore", "inherit"],
detached: true
Expand Down
16 changes: 8 additions & 8 deletions test/js/ruby/nodes/lambda.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ describe("lambda", () => {
return expect(`command :foo, -> { ${long} }`).toChangeFormat(
ruby(`
command :foo,
-> {
-> do
${long}
}
end
`)
);
});
Expand All @@ -51,9 +51,9 @@ describe("lambda", () => {
return expect(`command.call :foo, -> { ${long} }`).toChangeFormat(
ruby(`
command.call :foo,
-> {
-> do
${long}
}
end
`)
);
});
Expand All @@ -62,9 +62,9 @@ describe("lambda", () => {
return expect(`command :foo, bar: -> { ${long} }`).toChangeFormat(
ruby(`
command :foo,
bar: -> {
bar: -> do
${long}
}
end
`)
);
});
Expand All @@ -79,9 +79,9 @@ describe("lambda", () => {
${long},
a${long},
aa${long}
) {
) do
true
}
end
`)
);
});
Expand Down
Loading