Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit b956d32

Browse files
committed
open config file in local EDITOR, if user is connected via SSH
1 parent 8c835d7 commit b956d32

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/include/filesystem.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const fs = require('fs');
33
const path = require('path');
44
const open = require('open');
55
const find = require('find-in-files');
6+
const child_process = require('child_process');
67

78
class filesystem {
89
static find(pattern, dir) {
@@ -22,7 +23,14 @@ class filesystem {
2223
}
2324

2425
static open(file) {
26+
if ((process.env.SSH_CLIENT || process.env.SSH_TTY) && process.env.EDITOR) {
27+
var child = child_process.spawn(process.env.EDITOR, [file], {
28+
stdio: 'inherit'
29+
});
30+
return child;
31+
} else {
2532
return open(file);
33+
}
2634
}
2735

2836
static join(...args) {
@@ -38,4 +46,4 @@ class filesystem {
3846
}
3947
}
4048

41-
module.exports = filesystem;
49+
module.exports = filesystem;

0 commit comments

Comments
 (0)