Files
codeql/javascript/ql/test/ApiGraphs/promises/index.js
Max Schaefer 252902d245 JavaScript: Restructure API-graph tests.
With the old test runner we cannot have `VerifyAssertions.qlref`s for each individual test that reference a shared `VerifyAssertions.ql` in the parent directory, since it doesn't like nested tests.

Instead, we have to turn `VerifyAssertions.ql` into `VerifyAssertions.qll`, and each `VerifyAsssertions.qlref` into a `VerifyAssertions.ql` that imports it.

But then that doesn't work with our old directory structure, since the import path would have to contain the invalid identifier `library-tests`. As a workaround, I have moved the API graph tests into a directory without dashes in its path.
2020-09-04 08:43:15 +01:00

21 lines
730 B
JavaScript

const fs = require("fs"),
fse = require("fs-extra"),
base64 = require("base-64");
module.exports.readFile = function (f) {
return new Promise((res, rej) => {
fs.readFile(f, (err, data) => {
if (err)
rej(err);
else
res(data); /* def (promised (return (member readFile (member exports (module promises))))) */
});
});
};
module.exports.readFileAndEncode = function (f) {
return fse.readFile(f)
.then((data) => /* use (promised (return (member readFile (member exports (module fs-extra))))) */
base64.encode(data) /* def (promised (return (member readFileAndEncode (member exports (module promises))))) */
);
};