Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
Using Grunt to run Closure Compiler on the api
Browse files Browse the repository at this point in the history
  • Loading branch information
TATDK committed Mar 15, 2014
1 parent 5123fbc commit 7719cdc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Thumbs.db

# node.js #
node_modules
bin
lib
assets

Expand Down
22 changes: 22 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var fs = require('fs');

module.exports = function(grunt) {
grunt.initConfig({
closurecompiler: {
minify: {
files: {
'./bin/client.js': ['./src/client.js'],
'./bin/room.js': ['./src/room.js']
},
options: {
'compilation_level': 'SIMPLE_OPTIMIZATIONS',
banner: '/*' + fs.readFileSync('LICENSE.md') + '*/'
}
}
}
});

grunt.loadNpmTasks('grunt-closurecompiler');

grunt.registerTask('default', 'closurecompiler:minify');
}
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Originally by [Chris Vickery](https://github.com/chrisinajar), now maintained by
## How to use
Run the following:

```npm install plugapi```
```npm install plugapi --production```

To connect, do this!

Expand Down Expand Up @@ -60,7 +60,7 @@ Read about some of the events on the [wiki](https://github.com/TATDK/plugapi/wik

Read about the actions on the [wiki](https://github.com/TATDK/plugapi/wiki/actions).

##Misc
## Misc

#### setLogObject(logger)
You can set your own custom logger for the API to use when it logs important events, such as errors or stack traces from the server.
Expand All @@ -72,6 +72,14 @@ var prompt = new Prompt();
bot.setLogObject(prompt);
```

## Contribute
1. Clone repository to empty folder.
2. Cd to the repository.
3. Run `npm install` to set up the environment.
4. Edit your code.
5. Run `grunt` to compile the code and test.
6. After it's bug free, you may submit it as a Pull Request to the main repo.

#### Multi line chat
Since Plug.dj cuts off chat messages at 250 characters, you can choose to have your bot split up chat messages into multiple lines:

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"name": "Chris Bellew",
"email": "[email protected]"
}],
"main": "./src/client.js",
"lib": "./src/client.js",
"main": "./bin/client.js",
"keywords": [
"plug.dj",
"plug",
Expand All @@ -28,6 +27,10 @@
"request": "*",
"sockjs-client-node": "https://github.com/TATDK/sockjs-client-node/tarball/master"
},
"devDependencies": {
"grunt": "*",
"grunt-closurecompiler": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/TATDK/plugapi"
Expand Down
2 changes: 1 addition & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ PlugAPI.prototype.intChat = function(msg, timeout) {
chatID: cID
}]
}));
if (timeout !== undefined && ~~timeout !== NaN && ~~timeout > 0) {
if (timeout !== undefined && !isNaN(~~timeout) && ~~timeout > 0) {
setTimeout(function() {
_this.moderateDeleteChat(cID);
}, ~~timeout * 1E3);
Expand Down

0 comments on commit 7719cdc

Please sign in to comment.