Skip to content

Commit fac7c66

Browse files
devsnekMayaLekova
authored andcommitted
tools,bootstrap: preprocess gypi files to json
PR-URL: nodejs#19140 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 281b177 commit fac7c66

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
@@ -128,16 +128,9 @@ function setupMemoryUsage() {
128128
function setupConfig(_source) {
129129
// NativeModule._source
130130
// used for `process.config`, but not a real module
131-
var config = _source.config;
131+
const config = _source.config;
132132
delete _source.config;
133133

134-
// strip the gyp comment line at the beginning
135-
config = config.split('\n')
136-
.slice(1)
137-
.join('\n')
138-
.replace(/"/g, '\\"')
139-
.replace(/'/g, '"');
140-
141134
process.config = JSON.parse(config, function(key, value) {
142135
if (value === 'true') return true;
143136
if (value === 'false') return false;

tools/js2c.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ def JS2C(source, target):
292292
split = split[1:]
293293
name = '/'.join(split)
294294

295+
# if its a gypi file we're going to want it as json
296+
# later on anyway, so get it out of the way now
297+
if name.endswith(".gypi"):
298+
lines = re.sub(r'#.*?\n', '', lines)
299+
lines = re.sub(r'\'', '"', lines)
295300
name = name.split('.', 1)[0]
296301
var = name.replace('-', '_').replace('/', '_')
297302
key = '%s_key' % var

0 commit comments

Comments
 (0)