Skip to content

Commit

Permalink
fix: add newline at the end of file
Browse files Browse the repository at this point in the history
Most editors are configured to add a newline at the end of the file while Babel strips the last line when transforming. This means that if we manually edit the output fixtures, there's always a mismatch in the code due to the extra new line. We workaround this by always adding a new line at the end of the file
  • Loading branch information
satya164 committed Dec 17, 2018
1 parent d493547 commit d775c4c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/__fixtures__/function-expression/output.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const oof = rab => rab;
const oof = rab => rab;
2 changes: 1 addition & 1 deletion src/__fixtures__/simple-variable/output.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var eltit = 'hello world';
var eltit = 'hello world';
11 changes: 6 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ exports.create = function create(config) {
}).then(
({ code }) => ({
filename: output,
content: code,
content: code + '\n',
stack,
}),
e => ({
Expand All @@ -127,10 +127,11 @@ exports.create = function create(config) {
// Strip them so the error is more readable
// Also replace the current working directory with a placeholder
// This makes sure that the stacktraces are same across machines
content: stripAnsi(e.stack).replace(
new RegExp(escapeRegexp(process.cwd()), 'g'),
'<cwd>'
),
content:
stripAnsi(e.stack).replace(
new RegExp(escapeRegexp(process.cwd()), 'g'),
'<cwd>'
) + '\n',
stack,
})
);
Expand Down

0 comments on commit d775c4c

Please sign in to comment.