Skip to content

Commit 6a9dfcc

Browse files
committed
tools/bootstrap_node: preprocess gypi files to json
1 parent 3ed363c commit 6a9dfcc

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
@@ -122,16 +122,9 @@ function setupMemoryUsage() {
122122
function setupConfig(_source) {
123123
// NativeModule._source
124124
// used for `process.config`, but not a real module
125-
var config = _source.config;
125+
const config = _source.config;
126126
delete _source.config;
127127

128-
// strip the gyp comment line at the beginning
129-
config = config.split('\n')
130-
.slice(1)
131-
.join('\n')
132-
.replace(/"/g, '\\"')
133-
.replace(/'/g, '"');
134-
135128
process.config = JSON.parse(config, function(key, value) {
136129
if (value === 'true') return true;
137130
if (value === 'false') return false;

tools/js2c.py

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

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

0 commit comments

Comments
 (0)