Skip to content

Commit

Permalink
[watcher] Respect shebangs
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro committed Mar 25, 2012
1 parent 952982b commit 097d47d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 1 addition & 3 deletions bin/create_user_dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ var config = require('../config.js').opt;

var dirs_string = config.git_home_dir + '/' + process.argv[2] + ' ' + config.apps_home_dir + '/' + process.argv[2];

var cmds = ['mkdir ' + dirs_string, 'chown ' + config.git_user + ':' + config.app_uid + ' ' + dirs_string, 'chmod 0777 ' + dirs_string

];
var cmds = ['mkdir ' + dirs_string, 'chgrp -R '+config.chgrp+' ' +dirs_string, 'chmod 0777 ' + dirs_string];

var do_cmd = function () {
if (cmds.length > 0) {
Expand Down
10 changes: 9 additions & 1 deletion lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,15 @@ var insert_code = function(location,file,code, cb){
old = old.split('\n').filter(function(line){
return line !== code;
}).join('\n')
newfile = code+'\n\n'+old
)
var lines = old.split('\n');
if (/\#!\//gi.test(lines[0])){
var shebang = lines[0]
lines.shift();
newfile = shebang+'\n'+code+'\n'+lines.join('\n');
} else {
newfile = code+'\n'+old
}
var inserted = fs.createWriteStream(target, {'flags': 'w'},'utf8');
inserted.end(newfile);
exec('cd '+location+'; sudo git add .;sudo git commit -am "[nodester] Watcher code inserted"',function(e,d){
Expand Down

0 comments on commit 097d47d

Please sign in to comment.