Skip to content

Commit

Permalink
Merge pull request #17 from eirvandelden/main
Browse files Browse the repository at this point in the history
✨  When rails notes/about fails to run, save the error output and return it in the Extension error logs
  • Loading branch information
tommasongr authored Apr 14, 2022
2 parents 5081584 + 9951f68 commit e4d18b2
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,26 @@ export async function aboutRails() {
const process = new Process('/usr/bin/env', {
cwd: nova.workspace.path,
args: ['rails', 'about'],
stdio: ['ignore', 'pipe', 'ignore'],
stdio: ['ignore', 'pipe', 'pipe'],
shell: true,
})
let str = ''
let err = ''
let strings = []

process.onStdout((output) => {
str += output
})

process.onStderr((error_output) => {
err += error_output
})

process.onDidExit((status) => {
if (status == 1 && str.length == 0) {
return reject(err)
}

// Split each line of the output in the strings array
strings = str.match(/[^\r\n]+/g)

Expand All @@ -97,17 +106,26 @@ export async function railsNotes() {
const process = new Process('/usr/bin/env', {
cwd: nova.workspace.path,
args: ['rails', 'notes'],
stdio: ['ignore', 'pipe', 'ignore'],
stdio: ['ignore', 'pipe', 'pipe'],
shell: true,
})
let str = ''
let err = ''
let strings = []

process.onStdout((output) => {
str += output
})

process.onStderr((error_output) => {
err += error_output
})

process.onDidExit((status) => {
if (status == 1 && str.length == 0) {
return reject(err)
}

const notes = []
// Split each line of the output in the strings array
strings = str.match(/[^\r\n]+/g)
Expand Down

0 comments on commit e4d18b2

Please sign in to comment.