Skip to content

Commit

Permalink
inline tracer-env.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Brignull committed Aug 26, 2020
1 parent f5d645f commit 1c004b9
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 39 deletions.
20 changes: 18 additions & 2 deletions lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

21 changes: 0 additions & 21 deletions lib/tracer-env.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/tracer-env.js.map

This file was deleted.

21 changes: 19 additions & 2 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,31 @@ function getCodeQLForCmd(cmd: string): CodeQL {
]);
},
getTracerEnv: async function(databasePath: string) {
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'));
Expand Down
12 changes: 0 additions & 12 deletions src/tracer-env.ts

This file was deleted.

0 comments on commit 1c004b9

Please sign in to comment.