Skip to content
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

Merged
merged 5 commits into from
Mar 29, 2017
Merged

Convert File Package to js #6503

merged 5 commits into from
Mar 29, 2017

Conversation

MartinSchoeler
Copy link
Contributor

@MartinSchoeler MartinSchoeler commented Mar 27, 2017

@RocketChat/core

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-6503 March 27, 2017 19:37 Inactive
const path = Npm.require('path');
const mkdirp = Npm.require('mkdirp');
const gm = Npm.require('gm');
const exec = Npm.require('child_process').exec;
Copy link
Member

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() {
Copy link
Member

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({
Copy link
Member

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 = {};
}
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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 = {};
}
Copy link
Member

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;
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the comments

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-6503 March 29, 2017 16:26 Inactive
@engelgabriel engelgabriel added this to the 0.55.0 milestone Mar 29, 2017
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-6503 March 29, 2017 16:48 Inactive
@engelgabriel engelgabriel merged commit c5708f5 into develop Mar 29, 2017
@engelgabriel engelgabriel deleted the file-to-js branch March 29, 2017 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants