bigcode-astgen
Advanced tools
Comparing version 0.1.0 to 0.1.1
18
index.js
@@ -5,2 +5,3 @@ const fs = require('fs'); | ||
const parser = require('acorn/dist/acorn_loose'); | ||
const _ = require('lodash'); | ||
@@ -191,6 +192,12 @@ | ||
function generateAndOuputAST(filepath, streams, callback) { | ||
function generateAndOuputAST(filepath, streams, options, callback) { | ||
bigcodeASTGen.fromFile(filepath, function(err, ast) { | ||
if (!err && ast.length < options.minNodes) { | ||
err = 'too few nodes'; | ||
} | ||
if (!err && ast.length > options.maxNodes) { | ||
err = 'too many nodes'; | ||
} | ||
if (err) { | ||
streams.failedFiles.write(filepath + '\n'); | ||
streams.failedFiles.write(filepath + '\t' + err + '\n'); | ||
return callback(null); | ||
@@ -218,3 +225,3 @@ } | ||
function processFiles(files, streams, callback) { | ||
function processFiles(files, streams, options, callback) { | ||
console.log(`starting to process ${files.length} files`); | ||
@@ -226,3 +233,3 @@ | ||
} | ||
generateAndOuputAST(file, streams, cb); | ||
generateAndOuputAST(file, streams, options, cb); | ||
}; | ||
@@ -250,3 +257,4 @@ async.eachOfLimit(files, 30, processFile, (err) => { | ||
} | ||
processFiles(files, streams, callback); | ||
const processOptions = _.take(options, ['minNodes', 'maxNodes']); | ||
processFiles(files, streams, processOptions, callback); | ||
}); | ||
@@ -253,0 +261,0 @@ }); |
{ | ||
"name": "bigcode-astgen", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"repository": "https://github.com/tuvistavie/bigcode-tools.git", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12478
246