Hi, while using the generator under node v8.91, the following error is thrown
fs.js:75
throw new TypeError('"options" must be a string or an object, got ' +
^
TypeError: "options" must be a string or an object, got number instead.
at getOptions (fs.js:75:11)
at Object.fs.writeFile (fs.js:1261:13)
at C:/Users/RK/Documents/github/org/swagger-node-codegen/dist/codegen.js:127:18
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
This behaviour was updated in v8.x and the error being thrown is from the getOptions function from the node library v8.x
This was reported earlier #4 and as per the suggestion provided there removing 0 from the piece of code fixes this issue however those changes were not made part of the pull request.
Hi, while using the generator under node v8.91, the following error is thrown
fs.js:75 throw new TypeError('"options" must be a string or an object, got ' + ^
TypeError: "options" must be a string or an object, got number instead. at getOptions (fs.js:75:11) at Object.fs.writeFile (fs.js:1261:13) at C:/Users/RK/Documents/github/org/swagger-node-codegen/dist/codegen.js:127:18 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
This piece of code causing this is
fs.writeFile(target_file, content, 0, 'utf8', (err) => { if (err) throw err; });
at lines 47, 79 & 100 of lib/codegen.js https://github.com/fmvilas/swagger-node-codegen/blob/master/lib/codegen.jsThis was not an issue in node v6.x because passing 0 triggered the default options
https://github.com/nodejs/node/blob/v6.x/lib/fs.js line 1306 node v6.x lib/fs.js
fs.writeFile = function(path, data, options, callback_) { var callback = maybeCallback(arguments[arguments.length - 1]); if (!options || typeof options === 'function') { options = { encoding: 'utf8', mode: 0o666, flag: 'w' }; } else if (typeof options === 'string') { options = { encoding: options, mode: 0o666, flag: 'w' }; } else if (typeof options !== 'object') { throwOptionsError(options); }
This behaviour was updated in v8.x and the error being thrown is from the getOptions function from the node library v8.x
This was reported earlier #4 and as per the suggestion provided there removing 0 from the piece of code fixes this issue however those changes were not made part of the pull request.