inline tracer-env.js
This commit is contained in:
parent
f5d645fc73
commit
1c004b9275
6 changed files with 38 additions and 39 deletions
20
lib/codeql.js
generated
20
lib/codeql.js
generated
|
|
@ -236,14 +236,30 @@ function getCodeQLForCmd(cmd) {
|
|||
]);
|
||||
},
|
||||
getTracerEnv: async function (databasePath) {
|
||||
let envFile = path.resolve(databasePath, 'working', 'env.tmp');
|
||||
// Write tracer-env.js to a temp location. When running in CLI mode we can't rely
|
||||
// on this file existing so we have to create it ourselves.
|
||||
const tracerEnvJs = path.resolve(databasePath, 'working', 'tracer-env.js');
|
||||
fs.mkdirSync(path.dirname(tracerEnvJs), { recursive: true });
|
||||
fs.writeFileSync(tracerEnvJs, `
|
||||
const fs = require('fs');
|
||||
const env = {};
|
||||
for (let entry of Object.entries(process.env)) {
|
||||
const key = entry[0];
|
||||
const value = entry[1];
|
||||
if (typeof value !== 'undefined' && key !== '_' && !key.startsWith('JAVA_MAIN_CLASS_')) {
|
||||
env[key] = value;
|
||||
}
|
||||
}
|
||||
process.stdout.write(process.argv[2]);
|
||||
fs.writeFileSync(process.argv[2], JSON.stringify(env), 'utf-8');`);
|
||||
const envFile = path.resolve(databasePath, 'working', 'env.tmp');
|
||||
await exec.exec(cmd, [
|
||||
'database',
|
||||
'trace-command',
|
||||
databasePath,
|
||||
...getExtraOptionsFromEnv(['database', 'trace-command']),
|
||||
process.execPath,
|
||||
path.resolve(__dirname, 'tracer-env.js'),
|
||||
tracerEnvJs,
|
||||
envFile
|
||||
]);
|
||||
return JSON.parse(fs.readFileSync(envFile, 'utf-8'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue