Skip to content

Commit

Permalink
🐛 Trim outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
steelbrain committed Feb 11, 2016
1 parent 1e73922 commit 1ff7e66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions spec/helper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const stderrScript = path.join(__dirname, 'fixtures', 'stderr') +
const testFile = path.join(__dirname, 'fixtures', 'test.txt')
const packageJsonPath = fs.realpathSync(`${__dirname}/../package.json`)

const testContents = fs.readFileSync(testFile).toString()
const testContents = fs.readFileSync(testFile).toString().trim()

describe('linter helpers', function () {
describe('::exec*', function () {
Expand Down Expand Up @@ -68,8 +68,8 @@ describe('linter helpers', function () {
}, 'STDERR')

waitsForAsyncRejection(async function () {
return await helpers.exec(stderrScript, [])
}, 'STDERR\n')
return (await helpers.exec(stderrScript, [])).trim()
}, 'STDERR')
})

it('shows a nicer error for EACCESS', function () {
Expand All @@ -91,7 +91,7 @@ describe('linter helpers', function () {
})
expect(false).toBe(true)
} catch (_) {
expect(_.message).toBe('STDERR\n')
expect(_.message.trim()).toBe('STDERR')
}
})
})
Expand Down
8 changes: 4 additions & 4 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ export function exec(
exit() {
if (options.stream === 'stdout') {
if (data.stderr.length && options.throwOnStdErr) {
handleError(new Error(data.stderr.join('')))
handleError(new Error(data.stderr.join('').trim()))
} else {
resolve(data.stdout.join(''))
resolve(data.stdout.join('').trim())
}
} else if (options.stream === 'stderr') {
resolve(data.stderr.join(''))
resolve(data.stderr.join('').trim())
} else {
resolve({ stdout: data.stdout.join(''), stderr: data.stderr.join('') })
resolve({ stdout: data.stdout.join('').trim(), stderr: data.stderr.join('').trim() })
}
}
}
Expand Down

0 comments on commit 1ff7e66

Please sign in to comment.