Skip to content

Commit ef06619

Browse files
fix: handle top level primitives in the process module (#113)
1 parent bc9cea7 commit ef06619

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lib/module-declaration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const generateModuleDeclaration = (module, index, API) => {
126126
returnType = moduleMethod.returns
127127
// Account for methods on the process module that return a custom type/structure, we need to reference the Electron namespace to use these types
128128
if (module.name === 'process' && moduleMethod.returns.type !== 'Object' &&
129-
typeof moduleMethod.returns.type === 'string') {
129+
typeof moduleMethod.returns.type === 'string' && !utils.isPrimitive(moduleMethod.returns.type)) {
130130
returnType = `Electron.${moduleMethod.returns.type}`
131131
}
132132
}

lib/utils.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ const isEmitter = (module) => {
129129
return true
130130
}
131131
}
132+
const isPrimitive = (type) => {
133+
const primitives = [
134+
'boolean',
135+
'number',
136+
'any',
137+
'string'
138+
]
139+
return primitives.indexOf(type.toLowerCase().replace(/\[\]/g, '')) !== -1
140+
}
132141
const isOptional = (param) => {
133142
// Did we pass a "required"?
134143
if (typeof param.required !== 'undefined') {
@@ -194,4 +203,4 @@ const genMethodString = (paramInterfaces, module, moduleMethod, parameters, retu
194203
}).join(', ')}${includeType ? `) => ${returns ? typify(returns) : 'void'}` : ''}`
195204
}
196205

197-
module.exports = { extendArray, isEmitter, isOptional, paramify, typify, wrapComment, genMethodString }
206+
module.exports = { extendArray, isEmitter, isOptional, paramify, typify, wrapComment, genMethodString, isPrimitive }

vendor/fetch-docs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const mkdirp = require('mkdirp').sync
77
const os = require('os')
88

99
const downloadPath = path.join(os.tmpdir(), 'electron-api-tmp')
10-
const ELECTRON_COMMIT = '7a508ca587ecc1f66c51bbce14a5dae6b7147c3c'
10+
const ELECTRON_COMMIT = '83b7f2369a3d7301f1038171636c8704be8b6818'
1111

1212
rm(downloadPath)
1313

0 commit comments

Comments
 (0)