Skip to content

Commit

Permalink
chore(deprecation): updating buffer call in base64 converter (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanksdesign authored Jan 23, 2021
1 parent 8945c46 commit 5c1d718
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions __tests__/utils/convertToBase64.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ describe('utils', () => {
it('should return a string', () => {
expect(typeof convertToBase64('__tests__/__configs/test.json')).toBe('string');
});

it('should be a valid base64 string', () => {
expect(convertToBase64('__tests__/__json_files/simple.json'))
.toEqual('ewogICJmb28iOiAiYmFyIiwKICAiYmFyIjogIntmb299Igp9');
});
});
});
2 changes: 1 addition & 1 deletion lib/utils/convertToBase64.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function convertToBase64(filePath) {
throw new Error('filePath name must be a string');

var body = fs.readFileSync(filePath, 'binary');
return new Buffer(body, 'binary').toString('base64');
return Buffer.from(body, 'binary').toString('base64');
}

module.exports = convertToBase64;

0 comments on commit 5c1d718

Please sign in to comment.