Skip to content

Commit 8e47f17

Browse files
committed
Use default options if no file given
1 parent eef9ade commit 8e47f17

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/plugin.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ export async function spawnServer(opts, killOnExit = true) {
6767
const tmpdir = os.tmpdir();
6868
const filepath = path.join(tmpdir, `prettier-ruby-parser-${process.pid}.txt`);
6969

70-
const currentFile = opts.filepath || process.cwd();
70+
const default_options = {
71+
env: Object.assign({}, process.env, { LANG: getLang() }),
72+
stdio: ["ignore", "ignore", "inherit"],
73+
detached: true
74+
};
75+
const options = opts.filepath
76+
? { cwd: path.dirname(opts.filepath), ...default_options }
77+
: default_options;
7178

7279
const server = spawn(
7380
opts.rubyExecutablePath || "ruby",
@@ -76,12 +83,7 @@ export async function spawnServer(opts, killOnExit = true) {
7683
`--plugins=${getPlugins(opts).join(",")}`,
7784
filepath
7885
],
79-
{
80-
cwd: path.dirname(currentFile),
81-
env: Object.assign({}, process.env, { LANG: getLang() }),
82-
stdio: ["ignore", "ignore", "inherit"],
83-
detached: true
84-
}
86+
options,
8587
);
8688

8789
server.unref();

0 commit comments

Comments
 (0)