File tree 6 files changed +54
-33
lines changed
modules/swagger-codegen/src/main/resources
javascript-promise-es6/src
6 files changed +54
-33
lines changed Original file line number Diff line number Diff line change @@ -160,9 +160,15 @@ export default class ApiClient {
160
160
*/
161
161
{ {/emitJSDoc} }
162
162
isFileParam(param) {
163
- // fs.ReadStream in Node.js (but not in runtime like browserify)
164
- if (typeof window === ' undefined' && typeof require === ' function' && require(' fs' ) && param instanceof require(' fs' ).ReadStream) {
165
- return true ;
163
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
164
+ if (typeof require === ' function' ) {
165
+ let fs
166
+ try {
167
+ fs = require(' fs' )
168
+ } catch (err) { }
169
+ if (fs && fs.ReadStream && param instanceof fs.ReadStream) {
170
+ return true ;
171
+ }
166
172
}
167
173
168
174
// Buffer in Node.js
Original file line number Diff line number Diff line change 168
168
* @returns { Boolean} <code >true</code > if <code >param</code > represents a file.
169
169
*/
170
170
{ {/emitJSDoc} } exports.prototype.isFileParam = function(param) {
171
- // fs.ReadStream in Node.js (but not in runtime like browserify)
172
- if (typeof window === ' undefined' &&
173
- typeof require === ' function' &&
174
- require(' fs' ) &&
175
- param instanceof require(' fs' ).ReadStream) {
176
- return true ;
171
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
172
+ if (typeof require === ' function' ) {
173
+ var fs
174
+ try {
175
+ fs = require(' fs' )
176
+ } catch (err) { }
177
+ if (fs && fs.ReadStream && param instanceof fs.ReadStream) {
178
+ return true ;
179
+ }
177
180
}
178
181
// Buffer in Node.js
179
182
if (typeof Buffer === 'function' && param instanceof Buffer) {
Original file line number Diff line number Diff line change 174
174
* @returns {Boolean } <code>true</code> if <code>param</code> represents a file.
175
175
*/
176
176
exports . prototype . isFileParam = function ( param ) {
177
- // fs.ReadStream in Node.js (but not in runtime like browserify)
178
- if ( typeof window === 'undefined' &&
179
- typeof require === 'function' &&
180
- require ( 'fs' ) &&
181
- param instanceof require ( 'fs' ) . ReadStream ) {
182
- return true ;
177
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
178
+ if ( typeof require === 'function' ) {
179
+ var fs
180
+ try {
181
+ fs = require ( 'fs' )
182
+ } catch ( err ) { }
183
+ if ( fs && fs . ReadStream && param instanceof fs . ReadStream ) {
184
+ return true ;
185
+ }
183
186
}
184
187
// Buffer in Node.js
185
188
if ( typeof Buffer === 'function' && param instanceof Buffer ) {
Original file line number Diff line number Diff line change 174
174
* @returns {Boolean } <code>true</code> if <code>param</code> represents a file.
175
175
*/
176
176
exports . prototype . isFileParam = function ( param ) {
177
- // fs.ReadStream in Node.js (but not in runtime like browserify)
178
- if ( typeof window === 'undefined' &&
179
- typeof require === 'function' &&
180
- require ( 'fs' ) &&
181
- param instanceof require ( 'fs' ) . ReadStream ) {
182
- return true ;
177
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
178
+ if ( typeof require === 'function' ) {
179
+ var fs
180
+ try {
181
+ fs = require ( 'fs' )
182
+ } catch ( err ) { }
183
+ if ( fs && fs . ReadStream && param instanceof fs . ReadStream ) {
184
+ return true ;
185
+ }
183
186
}
184
187
// Buffer in Node.js
185
188
if ( typeof Buffer === 'function' && param instanceof Buffer ) {
Original file line number Diff line number Diff line change 174
174
* @returns {Boolean } <code>true</code> if <code>param</code> represents a file.
175
175
*/
176
176
exports . prototype . isFileParam = function ( param ) {
177
- // fs.ReadStream in Node.js (but not in runtime like browserify)
178
- if ( typeof window === 'undefined' &&
179
- typeof require === 'function' &&
180
- require ( 'fs' ) &&
181
- param instanceof require ( 'fs' ) . ReadStream ) {
182
- return true ;
177
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
178
+ if ( typeof require === 'function' ) {
179
+ var fs
180
+ try {
181
+ fs = require ( 'fs' )
182
+ } catch ( err ) { }
183
+ if ( fs && fs . ReadStream && param instanceof fs . ReadStream ) {
184
+ return true ;
185
+ }
183
186
}
184
187
// Buffer in Node.js
185
188
if ( typeof Buffer === 'function' && param instanceof Buffer ) {
Original file line number Diff line number Diff line change 174
174
* @returns {Boolean } <code>true</code> if <code>param</code> represents a file.
175
175
*/
176
176
exports . prototype . isFileParam = function ( param ) {
177
- // fs.ReadStream in Node.js (but not in runtime like browserify)
178
- if ( typeof window === 'undefined' &&
179
- typeof require === 'function' &&
180
- require ( 'fs' ) &&
181
- param instanceof require ( 'fs' ) . ReadStream ) {
182
- return true ;
177
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
178
+ if ( typeof require === 'function' ) {
179
+ var fs
180
+ try {
181
+ fs = require ( 'fs' )
182
+ } catch ( err ) { }
183
+ if ( fs && fs . ReadStream && param instanceof fs . ReadStream ) {
184
+ return true ;
185
+ }
183
186
}
184
187
// Buffer in Node.js
185
188
if ( typeof Buffer === 'function' && param instanceof Buffer ) {
You can’t perform that action at this time.
0 commit comments