Skip to content

Commit 37a5a6e

Browse files
authored
fix(host): Add Buffer to global scope in sandbox (fixes #141) (#143)
1 parent 289d40f commit 37a5a6e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/integration-tests/src/factory.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ describe('Plugin Factory (used by host)', () => {
3838
expect(
3939
await pluginObj.handleRequest('Global', 'function', ['loaded'])
4040
).toEqual(true);
41+
expect(
42+
await pluginObj.handleRequest('Global', 'function', ['Buffer'])
43+
).not.toEqual(undefined);
4144
expect(
4245
await pluginObj.handleRequest('Global', 'function', ['process'])
4346
).not.toContain(['chdir', 'exit']);

packages/neovim/src/host/factory.ts

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export interface Sandbox {
9999
module: NodeModule;
100100
require: (p: string) => any;
101101
console: { [key in keyof Console]?: Function };
102+
Buffer: typeof Buffer;
102103
}
103104

104105
function createSandbox(filename: string): Sandbox {
@@ -151,6 +152,9 @@ function createSandbox(filename: string): Sandbox {
151152
sandbox.process.stdout = devNull;
152153
sandbox.process.stderr = devNull;
153154

155+
// Buffer is no longer an owned property of 'global' variable in Node.js v12 (#141)
156+
sandbox.Buffer = global.Buffer;
157+
154158
return sandbox;
155159
}
156160

0 commit comments

Comments
 (0)