-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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 Version Package to JS #6494
Changes from 3 commits
1ba9861
51f6571
b30ac0e
d65d816
4178135
62cd55f
3d01b25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
//let Future, VersionCompiler, async, exec, os; | ||
|
||
let VersionCompiler = undefined; | ||
const exec = Npm.require('child_process').exec; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you can improve with |
||
const os = Npm.require('os'); | ||
const Future = Npm.require('fibers/future'); | ||
const async = Npm.require('async'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably can use imports here: import {exec} from 'child_process';
import os from 'os';
import Future from 'fibers/future';
import async from 'async'); Can you test this? |
||
|
||
Plugin.registerCompiler({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this to after the class declaration |
||
extensions: ['info'] | ||
}, function() { | ||
return new VersionCompiler(); | ||
}); | ||
|
||
VersionCompiler = (function() { | ||
function VersionCompiler() {} | ||
|
||
VersionCompiler.prototype.processFilesForTarget = function(files) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change this to the ES6 class format? |
||
const future = new Future; | ||
const processFile = function(file, cb) { | ||
if (!file.getDisplayPath().match(/rocketchat\.info$/)) { | ||
return cb(); | ||
} | ||
let output = JSON.parse(file.getContentsAsString()); | ||
output.build = { | ||
date: new Date().toISOString(), | ||
nodeVersion: process.version, | ||
arch: process.arch, | ||
platform: process.platform, | ||
osRelease: os.release(), | ||
totalMemory: os.totalmem(), | ||
freeMemory: os.freemem(), | ||
cpus: os.cpus().length | ||
}; | ||
if (process.env.TRAVIS_BUILD_NUMBER) { | ||
output.travis = { | ||
buildNumber: process.env.TRAVIS_BUILD_NUMBER, | ||
branch: process.env.TRAVIS_BRANCH, | ||
tag: process.env.TRAVIS_TAG | ||
}; | ||
} | ||
return exec('git log --pretty=format:\'%H%n%ad%n%an%n%s\' -n 1', function(err, result) { | ||
if (err == null) { | ||
result = result.split('\n'); | ||
output.commit = { | ||
hash: result.shift(), | ||
date: result.shift(), | ||
author: result.shift(), | ||
subject: result.join('\n') | ||
}; | ||
} | ||
return exec('git describe --abbrev=0 --tags', function(err, result) { | ||
if (err == null && output.commit != null) { | ||
output.commit.tag = result.replace('\n', ''); | ||
} | ||
return exec('git rev-parse --abbrev-ref HEAD', function(err, result) { | ||
if (err == null && output.commit != null) { | ||
output.commit.branch = result.replace('\n', ''); | ||
} | ||
output = `RocketChat.Info = ${ JSON.stringify(output, null, 4) };`; | ||
file.addJavaScript({ | ||
data: output, | ||
path: `${ file.getPathInPackage() }.js` | ||
}); | ||
return cb(); | ||
}); | ||
}); | ||
}); | ||
}; | ||
async.each(files, processFile, future.resolver()); | ||
return future.wait(); | ||
}; | ||
|
||
return VersionCompiler; | ||
|
||
}()); |
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 remove this?