-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert File Package to js #6503
Conversation
const path = Npm.require('path'); | ||
const mkdirp = Npm.require('mkdirp'); | ||
const gm = Npm.require('gm'); | ||
const exec = Npm.require('child_process').exec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert all this require
to import
const gm = Npm.require('gm'); | ||
const exec = Npm.require('child_process').exec; | ||
|
||
Grid.tryParseObjectId = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you keep the old comment?
return exec('convert -version', Meteor.bindEnvironment(function(error, stdout) { | ||
if ((error == null) && stdout.indexOf('ImageMagick') > -1) { | ||
if (RocketChatFile.enabled !== true) { | ||
RocketChatFile.gm = RocketChatFile.gm.subClass({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you keep the comments?
constructor(config) { | ||
if (config == null) { | ||
config = {}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use default value instead of this condition
config = {}; | ||
} | ||
let name = config.name; | ||
const transformWrite = config.transformWrite; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use const {name = 'file', transformWrite} = config;
deleteFile(fileName) { | ||
const file = this.findOne(fileName); | ||
if (file == null) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return undefined
constructor(config) { | ||
if (config == null) { | ||
config = {}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use default values
config = {}; | ||
} | ||
let absolutePath = config.absolutePath; | ||
const transformWrite = config.transformWrite; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use const const {absolutePath = '~/uploads', transformWrite} = config
;
const rs = this.createReadStream(fileName); | ||
return { | ||
readStream: rs, | ||
length: stat.size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the comments
@RocketChat/core