Skip to content

Commit

Permalink
removing lazy dependency to fix buffer warning (#1393)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtrifonov authored and vmutafov committed Jun 13, 2019
1 parent a98e652 commit 72a44e4
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 60 deletions.
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ task generateDtsgJar(type: Exec) {
}
}

task jsParserNPMInstall(type: Exec) {
doFirst {
workingDir "$TEST_APP_PATH/build-tools/jsparser"
if (isWinOs) {
commandLine "cmd", "/c", "npm", "install"
} else {
commandLine "npm", "install"
}
}
}

task generateSbgJar(type: Exec) {
doFirst {
workingDir "$TEST_APP_PATH"
Expand Down Expand Up @@ -328,6 +339,7 @@ task createNpmPackage(type: Exec) {
}

generateSbgJar.dependsOn(generateDtsgJar)
generateSbgJar.dependsOn(jsParserNPMInstall)
generateMdgJar.dependsOn(generateSbgJar)
createDistDir.dependsOn(generateMdgJar)

Expand Down
53 changes: 29 additions & 24 deletions test-app/build-tools/jsparser/js_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ loggingSettings = {
var fs = require("fs"),
babelParser = require("babylon"),
traverse = require("babel-traverse"),
split = require('split'),
logger = require('./helpers/logger')(loggingSettings),
path = require("path"),
es5_visitors = require("./visitors/es5-visitors"),
lazy = require("lazy"),
eol = require('os').EOL,

BUILD_TOOLS_DIR = `${__dirname}/../`,
Expand Down Expand Up @@ -99,17 +99,20 @@ readLinesFromFile(inputFilesPath, inputFiles, tsHelpersFilePath)
*/
function readLinesFromFile(filePath, outArr, resolveParameter) {
return new Promise(function (resolve, reject) {
new lazy(fs.createReadStream(filePath))
.lines
.forEach(function (line) {
fs.createReadStream(filePath)
.pipe(split())
.on('data', function (line) {
// skip empty lines
if(/\S/.test(line)) {
outArr.push(line.toString().trim());
}).on('pipe', function (err) {
if (err) {
return reject(err);
}

return resolve(resolveParameter)
});
}
})
.on('error', function(err) {
return reject(err);
})
.on('close', function(e) {
return resolve(resolveParameter)
});
});
}

Expand Down Expand Up @@ -144,19 +147,21 @@ function getFileAst(tsHelpersFilePath) {
*/
function readInterfaceNames(data, err) {
return new Promise(function (resolve, reject) {
new lazy(fs.createReadStream(interfacesNamesFilePath))
.lines
.forEach(function (line) {
interfaceNames.push(line.toString());
}).on('pipe', function (err) {
if (err) {
return reject(false);
}

inputDir = path.normalize(inputDir);

return resolve(inputDir);
});
fs.createReadStream(interfacesNamesFilePath)
.pipe(split())
.on('data', function (line) {
// skip empty lines
if(/\S/.test(line)) {
interfaceNames.push(line.toString().trim());
}
})
.on('error', function(e) {
return reject(false);
})
.on('close', function(e) {
inputDir = path.normalize(inputDir);
return resolve(inputDir);
});
})
}

Expand Down
54 changes: 31 additions & 23 deletions test-app/build-tools/jsparser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test-app/build-tools/jsparser/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ast-parser",
"name": "js-parser",
"version": "1.0.0",
"description": "javascript static analysis tool",
"main": "js_parser.js",
Expand All @@ -13,7 +13,7 @@
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
"babylon": "6.18.0",
"lazy": "1.0.11"
"split": "1.0.1"
},
"repository": "https://github.com/NativeScript/android-runtime",
"devDependencies": {
Expand Down
12 changes: 1 addition & 11 deletions test-app/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,4 @@ include ':app',

project(':static-binding-generator').projectDir = new File('build-tools/static-binding-generator')
project(':android-metadata-generator').projectDir = new File('build-tools/android-metadata-generator')
project(':dts-generator').projectDir = new File('build-tools/android-dts-generator/dts-generator')

def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
exec {
workingDir "$rootDir/build-tools/jsparser"
if (isWinOs) {
commandLine "cmd", "/c", "npm", "install"
} else {
commandLine "npm", "install"
}
}
project(':dts-generator').projectDir = new File('build-tools/android-dts-generator/dts-generator')

0 comments on commit 72a44e4

Please sign in to comment.