Moncader / rejs

Other
14 stars 1 forks source link

Add rejs cli for npm #1

Closed watilde closed 9 years ago

watilde commented 9 years ago

Hi @Moncader

I added cli for npm. Its behavior is the following:


Print help message

$ rejs -h
Usage:
    rejs [options] [file ...]

Examples:
    rejs foo.js bar.js baz.js
    rejs --out out.js foo.js bar.js baz.js

Options:
  -h, --help     Print this message
  -o, --out      Output to single file
  -v, --version  Print rejs version

Print rejs version

$ rejs -v
v0.0.2

Output to stdout

$ rejs samples/node/[^node]*.js
var namespace = {};(function() {

  namespace.one = {
    hello: {}
  };

}());(function(global) {

  global.namespace.one.hello.two = 'Hello, world!';

}(this));

Output to single file

$ rejs -o samples/node/out.js samples/node/[^node]*.js
$ cat samples/node/out.js
var namespace = {};(function() {

  namespace.one = {
    hello: {}
  };

}());(function(global) {

  global.namespace.one.hello.two = 'Hello, world!';

}(this));

Could you please any thought on this please? Thanks.

Moncader commented 9 years ago

Thanks! Just one request, which is to keep naming conventions consistent, I have a couple of rules for how we name variables.

Temporary, local variables are prefixed with 't' and file-wide or closure-wide members are prefixed with 'm'. Parameters to functions are prefixed with 'p'. require'd files can just be the name of the file like normal though as if it was an external library.

So for example your message variable would be renamed tMessage or mMessage. I'll merge this after those guidelines are met.

watilde commented 9 years ago

@Moncader Thanks for your review and seems good rules! I just fixed that. Well, I think maybe it's better to put CONTRIBUTING.md for writing them:)

Moncader commented 9 years ago

@watilde I'll add the rules in to the proper file once I get a bit of time! Thanks!

watilde commented 9 years ago

@Moncader Sorry for my overlooked, I've fixed for now at https://github.com/watilde/rejs/commit/5d07507aacd9bf6e675493c2315f8f4649cda89e Thanks :smiley_cat: