Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Add ability to customize command-line arguments passed to Ruby #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Your Config in Atom menu):
# ruby path. run `which ruby` to find the path.
'rubyExecutablePath': null

# additional arguments arguments passed to ruby.
# default: -c -w --external-encoding=utf-8 --internal-encoding=utf-8
# add -Ku if you experience problems with utf-8 encoding on macOS.
'rubyAdditionalArgs': '-Ku'

# ignored extensions, ERB and markdown files by default.
'ignoredExtensions': 'erb, md'
```
8 changes: 7 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default {
atom.config.observe('linter-ruby.rubyExecutablePath', (value) => {
this.executablePath = value;
}),
atom.config.observe('linter-ruby.rubyAdditionalArgs', (value) => {
this.additionalArgs = value;
}),
atom.config.observe('linter-ruby.ignoredExtensions', (value) => {
this.ignoredExtensions = value;
}),
Expand Down Expand Up @@ -44,13 +47,16 @@ export default {
return [];
}

const execArgs = [
const defaultExecArgs = [
'-c', // Check syntax only, no execution
'-w', // Turns on warnings
// Set the encoding to UTF-8
'--external-encoding=utf-8',
'--internal-encoding=utf-8',
];
const additionalArgs = this.additionalArgs.split(/\s+/);

const execArgs = defaultExecArgs.concat(additionalArgs);
const execOpts = {
stdin: fileText,
stream: 'stderr',
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
"type": "string",
"default": "ruby"
},
"rubyAdditionalArgs": {
"title": "Additional arguments passed to Ruby",
"description": "Default arguments: `-c -w --external-encoding=utf-8 --internal-encoding=utf-8`",
"type": "string",
"default": ""
},
"ignoredExtensions": {
"type": "array",
"default": [
Expand Down