Skip to content

Commit 4df93dc

Browse files
devsnekMylesBorins
authored andcommitted
tools,bootstrap: preprocess gypi files to json
PR-URL: #19140 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 98fe68f commit 4df93dc

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/internal/process.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,9 @@ function setupMemoryUsage(_memoryUsage) {
109109
function setupConfig(_source) {
110110
// NativeModule._source
111111
// used for `process.config`, but not a real module
112-
var config = _source.config;
112+
const config = _source.config;
113113
delete _source.config;
114114

115-
// strip the gyp comment line at the beginning
116-
config = config.split('\n')
117-
.slice(1)
118-
.join('\n')
119-
.replace(/"/g, '\\"')
120-
.replace(/'/g, '"');
121-
122115
process.config = JSON.parse(config, function(key, value) {
123116
if (value === 'true') return true;
124117
if (value === 'false') return false;

tools/js2c.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ def JS2C(source, target):
261261
if '/' in name or '\\' in name:
262262
name = '/'.join(re.split('/|\\\\', name)[1:])
263263

264+
# if its a gypi file we're going to want it as json
265+
# later on anyway, so get it out of the way now
266+
if name.endswith(".gypi"):
267+
lines = re.sub(r'#.*?\n', '', lines)
268+
lines = re.sub(r'\'', '"', lines)
264269
name = name.split('.', 1)[0]
265270
var = name.replace('-', '_').replace('/', '_')
266271
key = '%s_key' % var

0 commit comments

Comments
 (0)