Skip to content

Commit f405302

Browse files
Leighton Turnerleighton
authored andcommitted
Fixed activity messages command parser
1 parent ea56f52 commit f405302

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

activity.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ var client = require('./lib/client.js');
22

33
var values = (function(){
44
var args=process.argv.splice(2);
5-
65
if(args.length==0){
76
console.log('Usage: ./activity.js -t <timeout> -m "<message>"');
87
process.exit(1);
@@ -33,6 +32,14 @@ var values = (function(){
3332
};
3433

3534
args.forEach(function(v,i){
35+
if(v=='-t') {
36+
vals[v] = arg_parser[v](args[i+1]);
37+
} else if (v=='-m') {
38+
vals[v] = arg_parser[v](args.splice(i+1).join(" "));
39+
} else {
40+
new Error("No argument for "+v);
41+
}
42+
/*This suddenly stopped working when upgrading node
3643
if(v.charAt(0)=='-'){
3744
if(arg_parser[v]!==undefined){
3845
if(args.length>=i+2){
@@ -44,6 +51,7 @@ var values = (function(){
4451
throw Error('Could not parse arguments '+v);
4552
}
4653
}
54+
*/
4755
});
4856
return vals;
4957
}());
@@ -60,6 +68,7 @@ var updater = new client.UpdateClient({
6068
//,port : "3000"
6169
});
6270

71+
6372
updater.activity(values['-m'],values['-t'], function(res) {
6473
console.log('STATUS: ' + res.statusCode);
6574
res.setEncoding('utf8');

bin/activity

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
#!/bin/sh
22

3-
node ../activity.js $*
3+
#http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
4+
source="${BASH_SOURCE[0]}"
5+
while [ -h "$source" ]; do # resolve $source until the file is no longer a symlink
6+
dir="$( cd -P "$( dirname "$source" )" && pwd )"
7+
source="$(readlink "$source")"
8+
# if $source was a relative symlink, we need to resolve
9+
#it relative to the path where the symlink file was located
10+
[[ $source != /* ]] && source="$dir/$source"
11+
done
12+
dir="$( cd -P "$( dirname "$source" )" && pwd )"
13+
14+
project_dir="$(dirname "$dir")"
15+
16+
17+
node $project_dir/activity.js $*

0 commit comments

Comments
 (0)