Skip to content

Commit

Permalink
hide node DeprecationWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed May 5, 2023
1 parent c017914 commit 7e787ce
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions deployer/build-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ const nexeUpxPlugin = require('./utils/nexe-upx-plugin');
];

let jsbundle = fs.readFileSync(path.join(distPath, 'deployer.js'), "utf-8");
jsbundle = [
// prepend a Buffer polyfill to get rid of this damn `new Buffer()` DeprecationWarning (coming from somewhere deep within the node_modules...)
'(function() {',
'var Buffer = global.Buffer;',
'global.Buffer = function() {',
'if(typeof arguments[0] == "string")',
'return Buffer.from(arguments[0]);',
'else if(typeof arguments[0] == "number")',
'return Buffer.alloc(arguments[0]);',
'return new Buffer(arguments[0]);',
'};',
'Object.setPrototypeOf(global.Buffer, Buffer);',
'})();',
jsbundle,
].join("");
jsbundle = jsbundle.replace(/node:crypto/g, "crypto"); // ugly fix to replace `node:crypto` imports by `crypto`
fs.writeFileSync(path.join(distPath, 'deployer.compat.js'), jsbundle);

Expand Down

0 comments on commit 7e787ce

Please sign in to comment.