Skip to content

Commit

Permalink
Filter out files with EMSCRIPTEN code
Browse files Browse the repository at this point in the history
  • Loading branch information
max-leuthaeuser committed Jul 2, 2024
1 parent b72b63d commit 8a68633
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 21 deletions.
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const tsc = require("typescript");
const path = require("path");
const {join} = require("path");
const fs = require("fs");
const readline = require('readline');

const IGNORE_DIRS = [
"node_modules",
Expand Down Expand Up @@ -46,6 +47,20 @@ function countFileLines(filePath){
});
};

async function containsEmscripten(filePath) {
const fileStream = fs.createReadStream(filePath);
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
for await (const line of rl) {
if (line.startsWith("// EMSCRIPTEN_START_ASM")) {
return true;
}
}
return false;
}

async function getAllFiles(dir, extn, files, result, regex) {
var allFiles = files || fs.readdirSync(dir);
var allResults = result || [];
Expand Down Expand Up @@ -305,6 +320,10 @@ const createJSAst = async (options) => {
}

for (const file of srcFiles) {
if (containsEmscripten(file)) {
console.warn("Parsing", file, ":", "Skipped as it contains EMSCRIPTEN code");
continue;
}
try {
const ast = fileToJsAst(file);
writeAstFile(file, ast, options);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@joernio/astgen",
"version": "3.15.0",
"version": "3.16.0",
"description": "Generate JS/TS AST in json format with Babel",
"exports": "./index.js",
"keywords": [
Expand Down
53 changes: 33 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz"
integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==

"@babel/parser@^7.24.7":
version "7.24.7"
resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.24.7.tgz"
integrity sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==

"@babel/[email protected]":
version "7.18.4"
resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.18.4.tgz"
integrity sha512-FDge0dFazETFcxGw/EXzOkN8uJp0PC7Qbm+Pe9T+av2zlBpOgunFHkQPPn+eRuClU73JF+98D531UgayY89tow==

"@babel/parser@^7.22.10":
version "7.22.10"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.10.tgz#e37634f9a12a1716136c44624ef54283cabd3f55"
integrity sha512-lNbdGsQb9ekfsnjFGhEiF4hfFqGgfOP3H3d27re3n+CGhNuTSUEQdfWk556sTLNTloczcdM5TYF2LhzmDQKyvQ==

"@babel/[email protected]", "@babel/types@^7.18.2":
"@babel/types@^7.18.2", "@babel/[email protected]":
version "7.19.0"
resolved "https://registry.npmjs.org/@babel/types/-/types-7.19.0.tgz"
integrity sha512-YuGopBq3ke25BVSiS6fgF49Ul9gH1x70Bcr6bqRLjWCkcX8Hre1/5+z+IiWOIerRMSSEfGZVB9z9kyq7wVs9YA==
Expand Down Expand Up @@ -80,7 +80,7 @@
"@nodelib/fs.stat" "2.0.5"
run-parallel "^1.1.9"

"@nodelib/[email protected].5", "@nodelib/fs.stat@^2.0.2":
"@nodelib/fs.stat@^2.0.2", "@nodelib/[email protected].5":
version "2.0.5"
resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz"
integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==
Expand Down Expand Up @@ -403,7 +403,7 @@ into-stream@^6.0.0:
from2 "^2.3.0"
p-is-promise "^3.0.0"

[email protected], is-core-module@^2.9.0:
is-core-module@^2.9.0, [email protected]:
version "2.9.0"
resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz"
integrity sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==
Expand Down Expand Up @@ -640,7 +640,20 @@ rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"

readable-stream@^2.0.0, readable-stream@^2.1.4:
readable-stream@^2.0.0:
version "2.3.7"
resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz"
integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
isarray "~1.0.0"
process-nextick-args "~2.0.0"
safe-buffer "~5.1.1"
string_decoder "~1.1.1"
util-deprecate "~1.0.1"

readable-stream@^2.1.4:
version "2.3.7"
resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz"
integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==
Expand Down Expand Up @@ -738,6 +751,13 @@ stream-meter@^1.0.4:
dependencies:
readable-stream "^2.1.4"

string_decoder@^1.1.1, string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz"
integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
dependencies:
safe-buffer "~5.1.0"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
Expand All @@ -747,13 +767,6 @@ string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string_decoder@^1.1.1, string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz"
integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
dependencies:
safe-buffer "~5.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz"
Expand Down Expand Up @@ -823,10 +836,10 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"

typescript@^5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
typescript@^5.5.3:
version "5.5.3"
resolved "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz"
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==

universalify@^2.0.0:
version "2.0.0"
Expand Down

0 comments on commit 8a68633

Please sign in to comment.