Skip to content

Commit

Permalink
fix: Remove usage of deprecated Buffer constructor. (#5477) (#5731)
Browse files Browse the repository at this point in the history
**Summary**

Fixes #5477 and #5704.

Remove usager of deprecated `Buffer`constructor to avoid ugly warnings on Node 10.

**Test plan**

Existing test should pass.
  • Loading branch information
aduh95 authored and BYK committed Apr 26, 2018
1 parent cbc6c88 commit 5231984
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/registries/npm-registry.js
Expand Up @@ -338,8 +338,8 @@ export default class NpmRegistry extends Registry {
const username = this.getRegistryOrGlobalOption(registry, 'username');
const password = this.getRegistryOrGlobalOption(registry, '_password');
if (username && password) {
const pw = new Buffer(String(password), 'base64').toString();
return 'Basic ' + new Buffer(String(username) + ':' + pw).toString('base64');
const pw = Buffer.from(String(password), 'base64').toString();
return 'Basic ' + Buffer.from(String(username) + ':' + pw).toString('base64');
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/fs.js
Expand Up @@ -767,8 +767,8 @@ export function normalizeOS(body: string): string {
return body.replace(/\r\n/g, '\n');
}

const cr = new Buffer('\r', 'utf8')[0];
const lf = new Buffer('\n', 'utf8')[0];
const cr = '\r'.charCodeAt(0);
const lf = '\n'.charCodeAt(0);
async function getEolFromFile(path: string): Promise<string | void> {
if (!await exists(path)) {
Expand Down

0 comments on commit 5231984

Please sign in to comment.