handle references to external environment variables
use cross-env to enable env variables on Windows
This commit is contained in:
parent
a86db5d0d1
commit
6c769ac00d
30
editors/code/package-lock.json
generated
30
editors/code/package-lock.json
generated
@ -19,6 +19,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
||||||
"@typescript-eslint/parser": "^5.16.0",
|
"@typescript-eslint/parser": "^5.16.0",
|
||||||
"@vscode/test-electron": "^2.1.3",
|
"@vscode/test-electron": "^2.1.3",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
"esbuild": "^0.14.27",
|
"esbuild": "^0.14.27",
|
||||||
"eslint": "^8.11.0",
|
"eslint": "^8.11.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
@ -27,7 +28,7 @@
|
|||||||
"vsce": "^2.7.0"
|
"vsce": "^2.7.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.65.0"
|
"vscode": "^1.66.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@eslint/eslintrc": {
|
"node_modules/@eslint/eslintrc": {
|
||||||
@ -790,6 +791,24 @@
|
|||||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/cross-env": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"cross-spawn": "^7.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"cross-env": "src/bin/cross-env.js",
|
||||||
|
"cross-env-shell": "src/bin/cross-env-shell.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.14",
|
||||||
|
"npm": ">=6",
|
||||||
|
"yarn": ">=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
@ -4663,6 +4682,15 @@
|
|||||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"cross-env": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"cross-spawn": "^7.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cross-spawn": {
|
"cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
|
@ -33,12 +33,12 @@
|
|||||||
"lint": "tsfmt --verify && eslint -c .eslintrc.js --ext ts ./src ./tests",
|
"lint": "tsfmt --verify && eslint -c .eslintrc.js --ext ts ./src ./tests",
|
||||||
"fix": " tsfmt -r && eslint -c .eslintrc.js --ext ts ./src ./tests --fix",
|
"fix": " tsfmt -r && eslint -c .eslintrc.js --ext ts ./src ./tests --fix",
|
||||||
"pretest": "tsc && npm run build",
|
"pretest": "tsc && npm run build",
|
||||||
"test": "node ./out/tests/runTests.js"
|
"test": "cross-env TEST_VARIABLE=test node ./out/tests/runTests.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vscode-languageclient": "8.0.0-next.14",
|
|
||||||
"d3": "^7.3.0",
|
"d3": "^7.3.0",
|
||||||
"d3-graphviz": "^4.1.0"
|
"d3-graphviz": "^4.1.0",
|
||||||
|
"vscode-languageclient": "8.0.0-next.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "~14.17.5",
|
"@types/node": "~14.17.5",
|
||||||
@ -46,6 +46,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
||||||
"@typescript-eslint/parser": "^5.16.0",
|
"@typescript-eslint/parser": "^5.16.0",
|
||||||
"@vscode/test-electron": "^2.1.3",
|
"@vscode/test-electron": "^2.1.3",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
"esbuild": "^0.14.27",
|
"esbuild": "^0.14.27",
|
||||||
"eslint": "^8.11.0",
|
"eslint": "^8.11.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
|
@ -232,7 +232,30 @@ export function substituteVariablesInEnv(env: Env): Env {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const resolved = new Set<string>();
|
const resolved = new Set<string>();
|
||||||
// TODO: handle missing dependencies
|
for (const dep of missingDeps) {
|
||||||
|
const match = /(?<prefix>.*?):(?<body>.+)/.exec(dep);
|
||||||
|
if (match) {
|
||||||
|
const { prefix, body } = match.groups!;
|
||||||
|
if (prefix === 'env') {
|
||||||
|
const envName = body;
|
||||||
|
envWithDeps[dep] = {
|
||||||
|
value: process.env[envName] ?? '',
|
||||||
|
deps: []
|
||||||
|
};
|
||||||
|
resolved.add(dep);
|
||||||
|
} else {
|
||||||
|
// we can't handle other prefixes at the moment
|
||||||
|
// leave values as is, but still mark them as resolved
|
||||||
|
envWithDeps[dep] = {
|
||||||
|
value: '${' + dep + '}',
|
||||||
|
deps: []
|
||||||
|
};
|
||||||
|
resolved.add(dep);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO: handle VSCode variables
|
||||||
|
}
|
||||||
|
}
|
||||||
const toResolve = new Set(Object.keys(envWithDeps));
|
const toResolve = new Set(Object.keys(envWithDeps));
|
||||||
|
|
||||||
let leftToResolveSize;
|
let leftToResolveSize;
|
||||||
|
@ -37,5 +37,17 @@ export async function getTests(ctx: Context) {
|
|||||||
const actualEnv = await substituteVariablesInEnv(envJson);
|
const actualEnv = await substituteVariablesInEnv(envJson);
|
||||||
assert.deepStrictEqual(actualEnv, expectedEnv);
|
assert.deepStrictEqual(actualEnv, expectedEnv);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
suite.addTest('Should support external variables', async () => {
|
||||||
|
const envJson = {
|
||||||
|
USING_EXTERNAL_VAR: "${env:TEST_VARIABLE} test ${env:TEST_VARIABLE}"
|
||||||
|
};
|
||||||
|
const expectedEnv = {
|
||||||
|
USING_EXTERNAL_VAR: "test test test"
|
||||||
|
};
|
||||||
|
|
||||||
|
const actualEnv = await substituteVariablesInEnv(envJson);
|
||||||
|
assert.deepStrictEqual(actualEnv, expectedEnv);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user