Skip to content
Open
Prev Previous commit
Next Next commit
write json file from python
  • Loading branch information
aduh95 committed Feb 26, 2022
commit 9a5ec5f2aefe6cde71f4da01087dde1c61270c56
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