Skip to content

Commit

Permalink
+ Заполнение в bashrc
Browse files Browse the repository at this point in the history
  • Loading branch information
atnartur committed Aug 15, 2015
1 parent 4ed13fd commit 180ff9d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
7 changes: 4 additions & 3 deletions start.js
Expand Up @@ -68,10 +68,11 @@ async.series([ // предотвращаем асинхронность
operation = 'write';

if (task !== '*')
tasks[task][operation]();
console.log('задача', key, 'операция', operation, '-', tasks[task][operation]());
else{
for(var key in tasks) // пробегаемся по массиву задач и выполняем их
tasks[key][operation]();
for(var key in tasks){ // пробегаемся по массиву задач и выполняем их
console.log('задача', key, 'операция', operation, '-', tasks[key][operation]());
}
}
}
]);
Expand Down
20 changes: 9 additions & 11 deletions tasks/bashrc.js
Expand Up @@ -7,20 +7,24 @@ module.exports = {
return path.normalize(process.env.HOME + '/.bashrc');
},
get_code: function(){
var str = "http://" + global.config.edu_login + ":" + global.config.edu_pass + "@" + global.config.host + ":" + global.config.port + "/";
var str = "http://" + global.config.edu_login + ":" + global.config.edu_pass + "@" + global.config.proxy_host + ":" + global.config.proxy_port + "/";

return
var full = "\n" +
this.label_str + "\n" +
"export http_proxy='" + str + "'\n" +
"export ftp_proxy='" + str + "'\n" +
this.label_str
this.label_str + "\n";

return full;
},
check: function(){
var filepath = this.get_path();

if(!fs.existsSync(filepath))
return false;
else{
var content = fs.readFileSync(filepath);
var content = fs.readFileSync(filepath).toString();

if(content.indexOf(this.label_str) !== -1){
if(content.indexOf(this.get_code()) !== -1)
return true;
Expand All @@ -44,17 +48,11 @@ module.exports = {
}
}

if (!fs.accessSync(filepath)) {
console.error('Ошибка: недоступен файл', filepath, '. Запустите скрипт с правами администратора');
return false;
}

fs.appendFileSync(filepath, this.get_code());

return true;
}
},
remove: function(){

}
}
}

0 comments on commit 180ff9d

Please sign in to comment.