Skip to content

Commit de94245

Browse files
committed
fix(host): expose all global variables except for REMOVED_GLOBALS (fixes #141)
1 parent 534faff commit de94245

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

packages/neovim/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"typings": "./lib/index",
4343
"dependencies": {
4444
"@msgpack/msgpack": "^1.9.3",
45-
"lodash.defaults": "^4.2.0",
4645
"lodash.omit": "^4.5.0",
4746
"semver": "^7.1.1",
4847
"winston": "3.2.1"
@@ -53,7 +52,6 @@
5352
"@babel/preset-env": "^7.3.4",
5453
"@babel/preset-typescript": "^7.3.3",
5554
"@types/jest": "^24.0.24",
56-
"@types/lodash.defaults": "^4.2.6",
5755
"@types/lodash.omit": "^4.5.6",
5856
"@types/node": "10.17.x",
5957
"@types/which": "^1.3.2",

packages/neovim/src/host/factory.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as path from 'path';
22
import * as util from 'util';
33
import * as vm from 'vm';
44

5-
import defaults from 'lodash.defaults';
65
import omit from 'lodash.omit';
76

87
import { Neovim } from '../api/Neovim';
@@ -110,7 +109,12 @@ function createSandbox(filename: string): Sandbox {
110109
console: {},
111110
}) as Sandbox;
112111

113-
defaults(sandbox, global);
112+
// Use getOwnPropertyNames to iterate all global variables (#141)
113+
Object.getOwnPropertyNames(global)
114+
.filter(p => !sandbox.hasOwnProperty(p))
115+
.forEach(prop => {
116+
sandbox[prop] = global[prop];
117+
});
114118

115119
// Redirect console calls into logger
116120
Object.keys(console).forEach((k: keyof Console) => {

yarn.lock

-13
Original file line numberDiff line numberDiff line change
@@ -1804,13 +1804,6 @@
18041804
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339"
18051805
integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA==
18061806

1807-
"@types/lodash.defaults@^4.2.6":
1808-
version "4.2.6"
1809-
resolved "https://registry.yarnpkg.com/@types/lodash.defaults/-/lodash.defaults-4.2.6.tgz#4ac29d3dd80a42803397076600f5b129f4aef911"
1810-
integrity sha512-JsUJheQIG2Yf/n/QRUMGXT76/7x4tLU5i0kxIPeoOcTIh9yNzdEzCHWbwD8mTf+VncGwYZiho+F2u1pEBsGswA==
1811-
dependencies:
1812-
"@types/lodash" "*"
1813-
18141807
"@types/lodash.omit@^4.5.6":
18151808
version "4.5.6"
18161809
resolved "https://registry.yarnpkg.com/@types/lodash.omit/-/lodash.omit-4.5.6.tgz#f2a9518259e481a48ff7ec423420fa8fd58933e2"
@@ -5885,11 +5878,6 @@ lodash.clonedeep@^4.5.0:
58855878
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
58865879
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
58875880

5888-
lodash.defaults@^4.2.0:
5889-
version "4.2.0"
5890-
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
5891-
integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=
5892-
58935881
lodash.get@^4.4.2:
58945882
version "4.4.2"
58955883
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
@@ -6381,7 +6369,6 @@ neo-async@^2.6.0:
63816369
version "4.8.0"
63826370
dependencies:
63836371
"@msgpack/msgpack" "^1.9.3"
6384-
lodash.defaults "^4.2.0"
63856372
lodash.omit "^4.5.0"
63866373
semver "^7.1.1"
63876374
winston "3.2.1"

0 commit comments

Comments
 (0)