Skip to content

Commit

Permalink
write json file from python
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Feb 26, 2022
1 parent fbb89f2 commit 9a5ec5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/common/parseEslintConfigForKnownGlobals.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const searchLines = [
const restrictedGlobalLine = /^\s{4}- name:\s?([^#\s]+)/;
const closingLine = /^\s{0,3}[^#\s]/;

process.stdout.write('["process"');
const jsonFile = fs.openSync(path.join(__dirname, 'knownGlobals.json'), 'w')

fs.writeSync(jsonFile,'["process"');

const eslintConfig = readline.createInterface({
input: fs.createReadStream(
Expand All @@ -27,7 +29,7 @@ eslintConfig.on('line', (line) => {
if (isReadingGlobals) {
const match = restrictedGlobalLine.exec(line);
if (match != null) {
process.stdout.write(',' + JSON.stringify(match[1]));
fs.writeSync(jsonFile, ',' + JSON.stringify(match[1]));
} else if (closingLine.test(line)) {
isReadingGlobals = false;
}
Expand All @@ -38,5 +40,6 @@ eslintConfig.on('line', (line) => {
});

eslintConfig.once('close', () => {
process.stdout.write(']');
fs.writeSync(jsonFile, ']');
fs.closeSync(jsonFile)
});
1 change: 1 addition & 0 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,7 @@ def Main():
print("Can't determine the arch of: '%s'" % vm)
print(archEngineContext.stderr.rstrip())
continue
Execute([vm, 'test/common/parseEslintConfigForKnownGlobals.js'], context)
env = {
'mode': mode,
'system': utils.GuessOS(),
Expand Down

0 comments on commit 9a5ec5f

Please sign in to comment.