This commit is contained in:
Nick Fyson 2020-08-21 11:59:11 +01:00
Родитель bd54c20d3e
Коммит 2b27c68c84
6 изменённых файлов: 86 добавлений и 3 удалений

3
lib/codeql.js сгенерированный
Просмотреть файл

@ -22,6 +22,7 @@ const globalutil = __importStar(require("util"));
const v4_1 = __importDefault(require("uuid/v4"));
const api = __importStar(require("./api-client"));
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
const exec_wrapper_1 = require("./exec_wrapper");
const util = __importStar(require("./util"));
/**
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
@ -298,7 +299,7 @@ function getCodeQLForCmd(cmd) {
]);
},
finalizeDatabase: async function (databasePath) {
await exec.exec(cmd, [
await exec_wrapper_1.exec_wrapper(cmd, [
'database',
'finalize',
...getExtraOptionsFromEnv(['database', 'finalize']),

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

41
lib/exec_wrapper.js сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,41 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const exec = __importStar(require("@actions/exec"));
async function exec_wrapper(commandLine, args, options) {
var _a;
const originalListener = (_a = options) === null || _a === void 0 ? void 0 : _a.listeners;
let stdout = '';
let stderr = '';
let listeners = {
stdout: (data) => {
var _a, _b, _c;
stdout += data.toString();
// NB change behaviour to only write to stdout/err if no listener passed
process.stdout.write(data);
(_c = (_a = originalListener) === null || _a === void 0 ? void 0 : (_b = _a).stdout) === null || _c === void 0 ? void 0 : _c.call(_b, data);
},
stderr: (data) => {
var _a, _b, _c;
stderr += data.toString();
process.stderr.write(data);
(_c = (_a = originalListener) === null || _a === void 0 ? void 0 : (_b = _a).stderr) === null || _c === void 0 ? void 0 : _c.call(_b, data);
}
};
const returnCode = await exec.exec(commandLine, args, {
listeners: listeners,
...options
});
if (stderr === stdout) {
console.log('foo bar');
}
return returnCode;
}
exports.exec_wrapper = exec_wrapper;
//# sourceMappingURL=exec_wrapper.js.map

1
lib/exec_wrapper.js.map Normal file
Просмотреть файл

@ -0,0 +1 @@
{"version":3,"file":"exec_wrapper.js","sourceRoot":"","sources":["../src/exec_wrapper.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAG/B,KAAK,UAAU,YAAY,CAAC,WAAmB,EAAE,IAAe,EAAE,OAAwB;;IAE/F,MAAM,gBAAgB,SAAG,OAAO,0CAAE,SAAS,CAAC;IAE5C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,IAAI,SAAS,GAAG;QACd,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,wEAAwE;YACxE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,YAAA,gBAAgB,iDAAE,MAAM,mDAAG,IAAI,EAAE;QACnC,CAAC;QACD,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,YAAA,gBAAgB,iDAAE,MAAM,mDAAG,IAAI,EAAE;QACnC,CAAC;KACF,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAChC,WAAW,EACX,IAAI,EACJ;QACE,SAAS,EAAE,SAAS;QACpB,GAAG,OAAO;KACX,CAAC,CAAC;IAEL,IAAI,MAAM,KAAK,MAAM,EAAG;QACtB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;KACxB;IAED,OAAO,UAAU,CAAC;AAEpB,CAAC;AAnCD,oCAmCC"}

Просмотреть файл

@ -12,6 +12,7 @@ import uuidV4 from 'uuid/v4';
import * as api from './api-client';
import * as defaults from './defaults.json'; // Referenced from codeql-action-sync-tool!
import { exec_wrapper } from './exec_wrapper';
import { Language } from './languages';
import * as util from './util';
@ -390,7 +391,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
]);
},
finalizeDatabase: async function(databasePath: string) {
await exec.exec(cmd, [
await exec_wrapper(cmd, [
'database',
'finalize',
...getExtraOptionsFromEnv(['database', 'finalize']),

39
src/exec_wrapper.ts Normal file
Просмотреть файл

@ -0,0 +1,39 @@
import * as exec from '@actions/exec';
import * as im from '@actions/exec/lib/interfaces';
export async function exec_wrapper(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number> {
const originalListener = options?.listeners;
let stdout = '';
let stderr = '';
let listeners = {
stdout: (data: Buffer) => {
stdout += data.toString();
// NB change behaviour to only write to stdout/err if no listener passed
process.stdout.write(data);
originalListener?.stdout?.(data);
},
stderr: (data: Buffer) => {
stderr += data.toString();
process.stderr.write(data);
originalListener?.stderr?.(data);
}
};
const returnCode = await exec.exec(
commandLine,
args,
{
listeners: listeners,
...options
});
if (stderr === stdout ) {
console.log('foo bar');
}
return returnCode;
}