Add code to output required env to files
This commit is contained in:
parent
217483dfd6
commit
3ffe4b7421
3 changed files with 64 additions and 3 deletions
31
lib/runner.js
generated
31
lib/runner.js
generated
|
|
@ -81,7 +81,36 @@ program
|
||||||
codeql = await init_1.initCodeQL(undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), tempDir, toolsDir, 'runner', logger);
|
codeql = await init_1.initCodeQL(undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), tempDir, toolsDir, 'runner', logger);
|
||||||
}
|
}
|
||||||
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), cmd.githubAuth, parseGithubUrl(cmd.githubUrl), logger);
|
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), cmd.githubAuth, parseGithubUrl(cmd.githubUrl), logger);
|
||||||
await init_1.runInit(codeql, config);
|
const tracerConfig = await init_1.runInit(codeql, config);
|
||||||
|
if (tracerConfig !== undefined) {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
const batEnvFile = path.join(config.tempDir, 'codeql-env.bat');
|
||||||
|
const batEnvFileContents = Object.entries(tracerConfig.env)
|
||||||
|
.map(([key, value]) => `Set ${key}=${value}`)
|
||||||
|
.join('\n');
|
||||||
|
fs.writeFileSync(batEnvFile, batEnvFileContents);
|
||||||
|
const powershellEnvFile = path.join(config.tempDir, 'codeql-env.sh');
|
||||||
|
const powershellEnvFileContents = Object.entries(tracerConfig.env)
|
||||||
|
.map(([key, value]) => `$env:${key}="${value}"`)
|
||||||
|
.join('\n');
|
||||||
|
fs.writeFileSync(powershellEnvFile, powershellEnvFileContents);
|
||||||
|
logger.info(`CodeQL environment outputted to "${batEnvFileContents}" and "${powershellEnvFile}". ` +
|
||||||
|
`Please export these variables to future processes so the build can tbe traced. ` +
|
||||||
|
`If using cmd/batch run "call ${batEnvFileContents}" ` +
|
||||||
|
`or if using PowerShell run "cat ${powershellEnvFile} | Invoke-Expression".`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Assume that anything that's not windows is using a unix-style shell
|
||||||
|
const envFile = path.join(config.tempDir, 'codeql-env.sh');
|
||||||
|
const envFileContents = Object.entries(tracerConfig.env)
|
||||||
|
.map(([key, value]) => `${key}="${value}"`)
|
||||||
|
.join('\n');
|
||||||
|
fs.writeFileSync(envFile, envFileContents);
|
||||||
|
logger.info(`CodeQL environment outputted to "${envFile}". ` +
|
||||||
|
`Please export these variables to future processes so the build can tbe traced, ` +
|
||||||
|
`for example by running "source ${envFile}".`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error('Init failed');
|
logger.error('Init failed');
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -114,7 +114,39 @@ program
|
||||||
parseGithubUrl(cmd.githubUrl),
|
parseGithubUrl(cmd.githubUrl),
|
||||||
logger);
|
logger);
|
||||||
|
|
||||||
await runInit(codeql, config);
|
const tracerConfig = await runInit(codeql, config);
|
||||||
|
if (tracerConfig !== undefined) {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
const batEnvFile = path.join(config.tempDir, 'codeql-env.bat');
|
||||||
|
const batEnvFileContents = Object.entries(tracerConfig.env)
|
||||||
|
.map(([key, value]) => `Set ${key}=${value}`)
|
||||||
|
.join('\n');
|
||||||
|
fs.writeFileSync(batEnvFile, batEnvFileContents);
|
||||||
|
|
||||||
|
const powershellEnvFile = path.join(config.tempDir, 'codeql-env.sh');
|
||||||
|
const powershellEnvFileContents = Object.entries(tracerConfig.env)
|
||||||
|
.map(([key, value]) => `$env:${key}="${value}"`)
|
||||||
|
.join('\n');
|
||||||
|
fs.writeFileSync(powershellEnvFile, powershellEnvFileContents);
|
||||||
|
|
||||||
|
logger.info(`CodeQL environment outputted to "${batEnvFileContents}" and "${powershellEnvFile}". ` +
|
||||||
|
`Please export these variables to future processes so the build can tbe traced. ` +
|
||||||
|
`If using cmd/batch run "call ${batEnvFileContents}" ` +
|
||||||
|
`or if using PowerShell run "cat ${powershellEnvFile} | Invoke-Expression".`);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Assume that anything that's not windows is using a unix-style shell
|
||||||
|
const envFile = path.join(config.tempDir, 'codeql-env.sh');
|
||||||
|
const envFileContents = Object.entries(tracerConfig.env)
|
||||||
|
.map(([key, value]) => `${key}="${value}"`)
|
||||||
|
.join('\n');
|
||||||
|
fs.writeFileSync(envFile, envFileContents);
|
||||||
|
|
||||||
|
logger.info(`CodeQL environment outputted to "${envFile}". ` +
|
||||||
|
`Please export these variables to future processes so the build can tbe traced, ` +
|
||||||
|
`for example by running "source ${envFile}".`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Init failed');
|
logger.error('Init failed');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue